大佬教程收集整理的这篇文章主要介绍了在不使用 gmail smtp 的情况下发送电子邮件 nodemailer,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个使用 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 (将#修改为@)
以上是大佬教程为你收集整理的在不使用 gmail smtp 的情况下发送电子邮件 nodemailer全部内容,希望文章能够帮你解决在不使用 gmail smtp 的情况下发送电子邮件 nodemailer所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。