Javascript NodeMailer 登录无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26948516/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NodeMailer Invalid Login
提问by Sri Harsha
I am new to node.js programming .I am using nodemailer module for sending emails.
我是 node.js 编程的新手。我正在使用 nodemailer 模块发送电子邮件。
const nodemailer = require ('nodemailer'),
credentials=require('./credentials.js');
var mailTransport=nodemailer.createTransport({
service:'Gmail',
auth: {
user : credentials.gmail.user,
pass : credentials.gmail.password,
}
});
function sendMail(mail_id){
mailTransport.sendMail({
from: ' "my name" <[email protected]>',
to : mail_id, //[email protected]
subject : 'Hello',
text: "Hello How do u do ?",
},function(err,info){
if(err){
console.log('Unable to send the mail :'+err.message);
}
else{
console.log('Message response : '+info.response);
}
});
}
exports.sendMail=sendMail;
This is my program for sending emails to different users. But I am getting Invalid Login. I don't have any idea why this is coming . I am new to node.js and server side scripting.
I am using my gmail username and password for credentials.
Please help me.
这是我向不同用户发送电子邮件的程序。但我收到了Invalid Login。我不知道为什么会这样。我是 node.js 和服务器端脚本的新手。
我使用我的 gmail 用户名和密码作为凭据。
请帮我。
采纳答案by smartbart24
Did you double-check your login credentials? Also did you double-check your "from" adress to match your email?
您是否仔细检查了您的登录凭据?您是否还仔细检查了您的“发件人”地址以匹配您的电子邮件?
I used the nodemailer for some tests 3 weeks ago with the gmail example given on the github page and it worked like a charm:
3 周前,我使用 nodemailer 进行了一些测试,使用了 github 页面上给出的 gmail 示例,它的工作原理非常棒:
https://github.com/andris9/Nodemailer
https://github.com/andris9/Nodemailer
Invalid login indicates mistyped/wrong credentials.
无效登录表示输入错误/错误的凭据。
回答by Sachin
One reason could be the 'modern security standard' protection from Gmail.
原因之一可能是 Gmail 的“现代安全标准”保护。
Check you gmail inbox for any new mail having subject "Google Account: sign-in attempt blocked"
检查您的 Gmail 收件箱是否有任何主题为“Google 帐户:登录尝试被阻止”的新邮件
If yes, open the mail and click on the link https://www.google.com/settings/security/lesssecureapps
如果是,请打开邮件并点击链接https://www.google.com/settings/security/lesssecureapps
set 'Access for less secure apps' to 'Turn on'. Try again, it should be working now.
将“访问不太安全的应用程序”设置为“打开”。再试一次,它现在应该可以工作了。
回答by Sujay U N
U need to Enable Security for Apps :
你需要为应用程序启用安全性:
|*| If u r using gmail,
|*| 如果你使用gmail,
Use :
service: 'gmail',
Goto :
https://myaccount.google.com/lesssecureapps
Enable :
Allow less secure apps: ON
|*| If u r using yahoo,
|*| 如果你使用雅虎,
Use :
service: 'yahoo',
Goto :
https://login.yahoo.com/account/security
Enable :
Allow apps that use less secure sign in
|*| If u r using Live or Hotmail, No need to enable anything.
|*| 如果您使用 Live 或 Hotmail,则无需启用任何内容。
Use :
service: 'hotmail',
回答by Daniel Danielecki
Particularly 2 issues: or you don't have enabled Less Secure Appshttps://myaccount.google.com/lesssecureappsor you don't have enabled Display Unlock Captchahttps://accounts.google.com/DisplayUnlockCaptcha, you need to turn on both of them.
特别是 2 个问题:或者您没有启用不太安全的应用程序https://myaccount.google.com/lesssecureapps或者您没有启用Display Unlock Captcha https://accounts.google.com/DisplayUnlockCaptcha,您需要打开它们两个。

