我尝试通过邮件服务器使用Nodemailer发送邮件。当我将项目部署到生产模式时,它在localhost:8000上可以正常工作出现错误:'ECONNRESET'
fyi:我使用express作为后端并将此项目部署在window server 2012上
这是一个错误
错误无法发送邮件:错误:读取了ECONNRESET
在TCP.onStreamRead上(internal / stream_base_commons.js:201:27){
errno:“ ECONNRESET”,
代码:“ ESOCKET”,
syscall:“读取”,
命令:“ CONN”
这是代码
const nodemailer = require('nodemailer')
let transporter = nodemailer.createTransport({
host: 'mailserver',
port: port,
tls: {
rejectUnauthorized: false
},
}
)
function Emailsender(email, link) {
let mailOption = {
from: 'xxxxxxxx@company.org',
to: `${email}`,
subject: 'News',
text: link
}
transporter.sendMail(mailOption, function (err, data) {
if (err) {
console.log('error cannot sendmail:', err)
}
else {
console.log('Email has been send')
}
})
}