我使用以下配置通过Nodemailer发送电子邮件,但无法发送,并且抛出错误:getaddrinfo ENOTFOUND ssl://smtp.googlemail.com ssl://smtp.googlemail.com:587 at GetAddrInfoReqWrap.onlookup
配置:
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user: 'xxx@gmail.com',
pass: 'xxxx'
}
任何人都可以给我一个解决方案,以便尽快解决吗?
答案 0 :(得分:1)
答案 1 :(得分:0)
注意:确保您对以下链接的安全性降低了:
https://myaccount.google.com/security?pli=1#connectedapps
然后像这样配置nodemailer
:
var smtpTransport = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true, // use SSL
auth: {
user: 'user@gmail.com',
pass: 'pass'
}
});
答案 2 :(得分:0)
您需要做两件事: 1.添加您的服务提供商名称
let transporter = nodemailer.createTransport({
service: 'gmail',
port: 25,
secure: false,
auth: {
user: 'your_mail_address@gmail.com',
pass: 'pass'
}
});
请参阅以下链接:
答案 3 :(得分:0)
This works for me.
var transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
service: 'Gmail',
auth: {
user: 'user@gmail.com',
pass: '***'
}
});
var mailOptions = {
from: SOURCE_EMAIL,
to: to,
subject: 'send mail',
text: 'Your text is here'
};
var status = transporter.sendMail(mailOptions, function(error, info){
console.log('info...',info);
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});