【发布时间】:2018-04-13 22:20:40
【问题描述】:
我正在尝试在用户注册后发送邮件。 我为此使用nodemailer。 我的代码看起来像这样-
var transporter = nodemailer.createTransport({
service:"Mailjet", // sets automatically host, port and connection security settings
auth: {
user:'******',
pass:'*******'
}
});
var mailOptions = {
to:mailTo,
from:'******',
subject:'user registered',
text:'welcome user'
};
transporter.sendMail(mailOptions, function(err, info) {
if (err) {
logger.debug('error in sending email ' + err);
} else {
logger.debug('Message sent: ' + info.response);
};
当我在我的窗口机器上的本地主机上使用它时,邮件运行正常,但是当我在我的远程服务器上使用它时,它是一个 linux 服务器。 我收到以下错误:
错误--- {错误:连接超时 在 SMTPConnection._formatError (/root/root/server/cq-code/node_modules/nodemailer/lib/smtp-connection/index.js:557:19) 在 SMTPConnection._onError (/root/root/server/cq-code/node_modules/nodemailer/lib/smtp-connection/index.js:530:20) 在 Timeout._connectionTimeout.setTimeout (/root/root/server/cq-code/node_modules/nodemailer/lib/smtp-connection/index.js:248:18) 在 ontimeout (timers.js:471:11) 在 tryOnTimeout (timers.js:306:5) 在 Timer.listOnTimeout (timers.js:266:5) 代码:'ETIMEDOUT',命令:'CONN'} info----- undefined
【问题讨论】: