问题描述
我有一个使用 bell.net
电子邮件地址的企业电子邮件,在他们的网站上,它说使用 smtphm.sympatico.ca
作为 smtp 主机名,以及 port 25 / 587
...我有我的nodemailer 代码设置如下:
app.post('/sendBatchEmail',(req,res) => {
var emails = [];
var emailSubject = req.body.emailSubject;
var emailMessage = req.body.emailMessage;
//perform db2 send
var sendEmail = "select * from testemails"
ibmdb.open(ibmdbconnMaster,function (err,conn) {
if (err) return console.log(err);
conn.query(sendEmail,rows) {
if (err) {
console.log(err);
}
for (var i = 0; i < rows.length; i++) {
emails.push(rows[i].EMAIL)
}
//send email
async function main() {
let transporter = nodemailer.createTransport({
host: "smtphm.sympatico.ca",port: 25,secure: false,// true for 465,false for other ports
auth: {
user: "xxx@bell.net",pass: "xxx",},});
// send mail with defined transport object
let sendBatch = await transporter.sendMail({
from: "my1email@bell.net",// sender address
to: "myemail@gmail.com",bcc: emails,// list of receivers
subject: emailSubject,// Subject line
text: emailMessage,// plain text body
});
console.log("Message sent: %s",sendBatch.messageId);
// Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>
// Preview only available when sending through an Ethereal account
// console.log("Preview URL: %s",sendBatch.getTestMessageUrl);
// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
}
main().catch(console.error);
res.redirect("/");
conn.close(function () {
console.log("closed the function app.get(/sendEmailBatch)");
});
});
});
})
但是,这不起作用并给我这个错误:
Error: Invalid login: 535 Authentication Failed
at SMTPConnection._formatError (/Users/ga/Desktop/PSL/mbs/node_modules/nodemailer/lib/smtp-connection/index.js:774:19)
at SMTPConnection._actionAUTHComplete (/Users/ga/Desktop/PSL/mbs/node_modules/nodemailer/lib/smtp-connection/index.js:1513:34)
at SMTPConnection.<anonymous> (/Users/ga/Desktop/PSL/mbs/node_modules/nodemailer/lib/smtp-connection/index.js:540:26)
at SMTPConnection._processResponse (/Users/ga/Desktop/PSL/mmbs/node_modules/nodemailer/lib/smtp-connection/index.js:932:20)
at SMTPConnection._onData (/Users/ga/Desktop/PSL/mbs/node_modules/nodemailer/lib/smtp-connection/index.js:739:14)
at TLSSocket.SMTPConnection._onSocketData (/Users/ga/Desktop/PSL/mbs/node_modules/nodemailer/lib/smtp-connection/index.js:189:44)
at TLSSocket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at TLSSocket.Readable.push (internal/streams/readable.js:223:10) {
code: 'EAUTH',response: '535 Authentication Failed',responseCode: 535,command: 'AUTH PLAIN'
}
但是当我将其改回 gmail 时有效...有什么想法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)