我希望网站每次访问“ / email”都发送一封电子邮件。 (我的确接受了,接受允许安全性较差的应用访问我的Google帐户中的帐户设置)。但是,它实际上从未向我发送电子邮件,而是给了我一个错误。
{ Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials d51sm16118087qtd.35 - gsmtp
at SMTPConnection._formatError (/Users/jenniferzhou/Documents/2018 - 2019/CS5150/Bethe-OPS-Project/node_modules/nodemailer/lib/smtp-connection/index.js:774:19)
at SMTPConnection._actionAUTHComplete (/Users/jenniferzhou/Documents/2018 - 2019/CS5150/Bethe-OPS-Project/node_modules/nodemailer/lib/smtp-connection/index.js:1509:34)
at SMTPConnection._responseActions.push.str (/Users/jenniferzhou/Documents/2018 - 2019/CS5150/Bethe-OPS-Project/node_modules/nodemailer/lib/smtp-connection/index.js:547:26)
at SMTPConnection._processResponse (/Users/jenniferzhou/Documents/2018 - 2019/CS5150/Bethe-OPS-Project/node_modules/nodemailer/lib/smtp-connection/index.js:933:20)
at SMTPConnection._onData (/Users/jenniferzhou/Documents/2018 - 2019/CS5150/Bethe-OPS-Project/node_modules/nodemailer/lib/smtp-connection/index.js:739:14)
at TLSSocket._socket.on.chunk (/Users/jenniferzhou/Documents/2018 - 2019/CS5150/Bethe-OPS-Project/node_modules/nodemailer/lib/smtp-connection/index.js:691:47)
at TLSSocket.emit (events.js:188:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at TLSSocket.Readable.push (_stream_readable.js:224:10)
code: 'EAUTH',
response:
'535-5.7.8 Username and Password not accepted. Learn more at\n535 5.7.8 https://support.google.com/mail/?p=BadCredentials d51sm16118087qtd.35 - gsmtp',
responseCode: 535,
command: 'AUTH PLAIN' }
这是我的以下代码。谁能帮忙吗?
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'senderemail',
pass: 'passwordtosenderemail'
}
});
const mailOptions = {
from: 'betheops@gmail.com',
to: 'emailreceiver@email.com',
subject: 'This is a test email',
html: '<p>This is a test</p>'
};
app.get('/email', function(req, res) {
transporter.sendMail(mailOptions, function(err, info) {
if (err)
console.log(err)
else
console.log(info);
});
})