我正在将nodemailer与gmail一起使用,并且我需要以某种方式包含我的密码。问题是我的密码同时包含单引号和双引号。例如我的“烦人的”密码。
我尝试转义任一引号,但 Google 拒绝我的密码。
“我的\”烦人的'密码”
'我的“烦人的\'密码'
我可以正常登录,但无法在我的脚本中使用它。
这是创建邮件程序对象的代码。
var mailer = email.createTransport({
service : "gmail",
auth : {
user : "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="137e6a767e727a7f53747e727a7f3d707c7e" rel="noreferrer noopener nofollow">[email protected]</a>",
// neither of these work
password : "my\"annoying'password",
// password : 'my"annoying\'password',
}
});
这可能吗?还是我必须更改密码?
更新
我得到的错误是:
[Error: Invalid login]
code: 'EAUTH',
response: '535-5.7.8 Username and Password not accepted.
最佳答案
抱歉。我真是个傻子。
var mailer = email.createTransport({
service : "gmail",
auth : {
user : "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="107d69757d71797c50777d71797c3e737f7d" rel="noreferrer noopener nofollow">[email protected]</a>",
// neither of these work
pass : "my\"annoying'password",
// pass : 'my"annoying\'password',
}
});
不是
var mailer = email.createTransport({
service : "gmail",
auth : {
user : "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="85e8fce0e8e4ece9c5e2e8e4ece9abe6eae8" rel="noreferrer noopener nofollow">[email protected]</a>",
// neither of these work
password : "my\"annoying'password",
// password : 'my"annoying\'password',
}
});
请注意,password:
更改为 pass:
关于javascript - Nodemailer 和 Node 中的密码问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27843258/