javascript - 在不使用 gmail smtp 的情况下发送电子邮件 nodemailer
问题描述
我有一封使用bell.net
电子邮件地址的企业电子邮件,在他们的网站上,它说 use 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, function (err, 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时可以使用...有什么想法吗?
解决方案
推荐阅读
- c - 使用自动生成的 makefile 包含 C 头文件的问题
- arrays - 在颤动的冻结类中更新深度嵌套的数组
- javascript - Javascript / 剪贴板 API / Safari iOS / NotAllowedError 消息
- python - PySpark - 将异构数组 JSON 数组转换为 Spark 数据帧并将其展平
- javascript - 对象元素的隐式绑定分配?(JavaScript 箭头函数,Ch05 Eloquent JS)
- html - 在源自具有角度的 Web api 的数组中选择不同的值
- android - 将设计应用于 Android 中的按钮子集
- python-3.x - 如何在我的 VPS 后台运行我的 python 脚本
- azure - 使用 IBM.Data.DB2.Core 连接到 DB2 - 尝试打开连接时出错 - 长度不能小于零。(参数“长度”)
- python-3.x - 确定列表中数字之间的差异