我整天都在努力让nodemailer使用我的Yahoo帐户。我现在收到以下身份验证错误:
Error: Invalid login: 535 5.7.1 Authentication failed
at SMTPConnection._formatError
...
code: 'EAUTH',
response: '535 5.7.1 Authentication failed',
responseCode: 535,
command: 'AUTH PLAIN' }
对我来说,使用Oauth毫无意义,因为我的应用无需登录。我只是使用nodemailer允许访问者在输入中请求公司的免费报价,然后将该文本发送到公司的yahoo收件箱中。我在想这一切错吗?这是我的控制器,以帮助提供任何上下文:
require('dotenv').config()
var nodemailer = require('nodemailer');
module.exports = {
sendEmail: (req,res) => {
console.log('-----hit', req.body)
const { name, email, text } = req.body
console.log('req.body', name, email, text)
var transporter = nodemailer.createTransport({
service: 'yahoo',
auth: {
user: process.env.NODEMAILER_ADDRESS,
pass: process.env.NODEMAILER_PASSWORD
},
tls: {
rejectUnauthorized: false
}
})
var mailOptions = {
from: name + ' ' + process.env.NODEMAILER_ADDRESS,
to: process.env.NODEMAILER_ADDRESS,
subject: 'New Message From ' + name,
text: name + ' ' + email + ' ' + text
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
})
}
}