如何解决在 vps 主机上部署后无法使用 nodemailer 发送电子邮件
我厌倦了这个。所以我的问题是我正在尝试在 centos 上使用 nodejs nodemailer 发送电子邮件 vps服务器。 在本地它工作正常。但部署后不起作用。
var nodemailer = require('nodemailer');
var Email = require('email-templates');
module.exports = {
sendPaymentMail: async (toEmail,mailSubject,templateName,locale) => {
if (process.env.SEND_EMAIL === "true") {
const configOption = {
host: process.env.SMTP_HOST,port: process.env.SMTP_PORT,secure: false,auth: {
user: process.env.SMTP_USER,pass: process.env.SMTP_PASSWORD
}
};
const viewPath = 'src/views/emails';
const transporter = await nodemailer.createTransport(configOption);
const email = new Email({
transport: transporter,send: true,preview: false,views: {
options: {
extension: 'pug'
},root: viewPath
}
});
// send mail with defined transport object
const info = await email.send({
template: templateName,message: {
from: process.env.SMTP_USER,to: toEmail,subject: mailSubject
},locals: locale
});
if (info) {
console.log('Message sent: %s',info.messageId);
}
return info;
} else {
return true;
}
}
};
端口是 587。我还启用了安全性较低的应用程序和验证码。我认为是因为港口 在centos vps 服务器上被阻止。我检查我得到了这个
我已经尝试了 2 天,但没有任何解决方案。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。