首页 > 解决方案 > nodemailer 解析 localhost 而不是 smtp 传输定义

问题描述

我有以下配置

{
  host: 'smtp.sendgrid.net',
  port: 587,
  secure: false,
  auth: {
    user: 'apikey',
    pass: this.configService.get<string>('SENDGRID_API_KEY'),
  },
}

但 nodemailer 正在解析 localhost 提供程序。我收到以下错误:

Error: connect ECONNREFUSED 127.0.0.1:587
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
  errno: 'ECONNREFUSED',
  code: 'ESOCKET',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 587,
  command: 'CONN'
}

任何帮助,将不胜感激。

标签: node.jsnestjsnodemailer

解决方案


推荐阅读