安全地存储密码的nodemailer

编程入门 行业动态 更新时间:2024-10-26 08:20:31
本文介绍了安全地存储密码的nodemailer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个使用 nodemailer 发送邮件的应用.

I have an app that sends mail using nodemailer.

transporter = nodemailer.createTransport({ service: 'Gmail', auth: { user: "email", pass: "what here?" } });

我只是想让应用保持开源状态(只是不想让纯文本密码基本上存在于任何地方).

I want to keep the app open source, just for the heck of it (along with not wanting a plain text password to exist basically anywhere).

我知道nodemailler-direct,但是这里有更好的选择吗?我还考虑过提示服务器控制台输入密码,但这也很麻烦.

I know of nodemailler-direct, but is there a better option here? I also thought about prompting the server console for password, but that's clunky as well.

是否有正确"或标准的方式来做这种事情?

Is there a "correct" or standard way to do such a thing?

推荐答案

使用环境变量:

transporter = nodemailer.createTransport({ service: process.env.NODEMAILER_SERVICE, auth: { user: process.env.NODEMAILER_USER, pass: process.env.NODEMAILER_PASS } });

您可以在服务器上设置这些变量,应用程序将对其进行提取.例如:

You can set these variables on the server and the application will pick them up. For example:

NODEMAILER_SERVICE="Gmail"

更多推荐

安全地存储密码的nodemailer

本文发布于:2023-11-07 22:28:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1567611.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:密码   nodemailer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!