Nodemailer正在发送邮件,但随后突然停止,现在给我这个错误

时间:2019-08-12 07:18:57

标签: javascript node.js nodemailer

这就像几天前一样工作,但是后来停止了。我真的不知道发生了什么。 PS:我在Mac上,看起来好像不是防火墙问题。

exports.sendEmail = (recipient, subject) => {
  const mailTransporter = nodeMailer.createTransport({
    service: 'gmail',
    host: 'smtp.gmail.com',
    port: 465,
    secure: true,
    auth: {
      user: process.env.EMAIL_USER,
      pass: process.env.EMAIL_PASS
    }
  })

  const mailOptions = {
    from: process.env.EMAIL_USER,
    to: recipient,
    subject,
    html: htmlTemplate(generatePasswordResetLink(),recipient),
  }

  return mailTransporter.sendMail(mailOptions, (error, success) => {
    if (error) {
     console.log(error);
      return error;
    }
    return success;
  })

代码中的console.log(error);会为此

{ Error: connect ECONNREFUSED 74.125.133.109:465
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)
  errno: 'ECONNREFUSED',
  code: 'ESOCKET',
  syscall: 'connect',
  address: '74.125.133.109',
  port: 465,
  command: 'CONN' }

我已经尽一切可能使它正常工作。我还重新启动了笔记本电脑。

PS:

user: 'a valid gmail account',
pass: 'correct pass for the account'

0 个答案:

没有答案