我在使用应该通过 SMTP 传输器发送电子邮件的 nodemailer Firebase 功能时遇到问题。
这很奇怪,因为我正在使用以下方法测试我的连接是否成功:
// check server readiness
const serverReady = await new Promise<boolean>(resolve => {
transporter.verify( (err: any, succ: any) => {
if (err) {
console.log(err);
resolve(false);
} else {
console.log('Server is ready to take our messages');
resolve(true);
}
});
})
打印服务器已准备好接收我们的消息
。
然后在设置我的信封并使用 .sendMail
方法发送后,我收到此错误:
Unhandled error { Error: Mail command failed: 530 5.5.1 Authentication Required.
at SMTPConnection._formatError (/srv/node_modules/nodemailer/lib/smtp-connection/index.js:777:19)
at SMTPConnection._actionMAIL (/srv/node_modules/nodemailer/lib/smtp-connection/index.js:1546:34)
at SMTPConnection._responseActions.push.str (/srv/node_modules/nodemailer/lib/smtp-connection/index.js:1028:18)
at SMTPConnection._processResponse (/srv/node_modules/nodemailer/lib/smtp-connection/index.js:935:20)
at SMTPConnection._onData (/srv/node_modules/nodemailer/lib/smtp-connection/index.js:742:14)
at TLSSocket.SMTPConnection._onSocketData.chunk (/srv/node_modules/nodemailer/lib/smtp-connection/index.js:195:44)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at TLSSocket.Readable.push (_stream_readable.js:208:10)
at TLSWrap.onread (net.js:601:20)
code: 'EENVELOPE',
response: '530 5.5.1 Authentication Required.',
responseCode: 530,
command: 'MAIL FROM' }
错误非常明显:身份验证失败
,但很奇怪,因为测试之前就成功了!
连接参数为:
// options to connect to server
const smtpOptions = {
host: 'smtp.zoho.eu',
port: 465,
secure: true,
auth: {
user: functions.config().nodemailer.user,
pass: functions.config().nodemailer.pass
}
};
// transporter for sending the email
const transporter = nodeMail.createTransport( smtpOptions );
先谢谢大家了
最佳答案
transporter.verify
仅测试连接和身份验证,看起来您无权使用特定的 MAIL FROM
地址。
关于node.js - Node.js 中的 Nodemailer : Failed auth although tested with success,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59201089/