Nodemailer错误:socket挂断

时间:2017-08-11 10:32:47

标签: javascript node.js smtp nodemailer

我正在尝试使用nodemailer通过我们的smtp服务器发送电子邮件,但我收到此错误:

{ Error: socket hang up
at TLSSocket.onHangUp (_tls_wrap.js:1117:19)
at Object.onceWrapper (events.js:290:19)
at emitNone (events.js:91:20)
at TLSSocket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9) code: 'ECONNECTION', command: 'CONN' }

代码如下:

let transporter = nodemailer.createTransport({
    host: "<corporative host>",
    port: 465,
    debug: true,
    secure: true,
    auth: {
      user: "<my_user>",
      pass: "<my password>"
    }
});

let mailOptions = {
    from: "myuser@host", // sender address
    to: "test@test.org", // list of receivers
    subject: "Hello ✔", // Subject line
    text: "Hello world ?", // plain text body
    html: "<b>Hello world ?</b>" // html body
};


transporter.sendMail(mailOptions, (error, info) => {
    console.log("SENDING");
    if (error) {
         return console.log(error);
    }
    console.log("Message %s sent: %s", info.messageId, info.response);
});

有人可以解释一下这个错误来自何处以及如何解决?

0 个答案:

没有答案