node.js - sendgrid 使用 @sendgrid/mail 设置

标签 node.js sendgrid

当我尝试使用 npm 包 sendgrid/mail 发送电子邮件时,有时会弹出此错误消息。这在大多数情况下都有效。

{ Error: connect ETIMEDOUT 169.45.89.179:443 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1104:14) errno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect',
address: '169.45.89.179', port: 443 } [bugsnag] Reported an unhandled rejection… Error: Error: connect ETIMEDOUT 169.45.89.179:443 at SendGrid.send.then.catch.e (/home/leoqiu/foodnome-api/build/src/utils/emailHelpers.js:143:11)

我的 Node 服务器使用以下代码发送它:

export const sendVerifyMail = (to: string, token: string) =>
  SendGrid.send({
    to,
    from: { email: '..' },
    subject: 'Verify you..',
    dynamic_template_data: {
      header: 'Verify your account',
      text:
        'Please use the button below to continue the process.',
      c2a_link: `${serverAddress}/api/user-account/verify?token=${token}`,
      c2a_button: 'Verify'
    },
    template_id: 'd-0f6411434fbc4896bf389e3945affd5d'
  } as any)
    .then(d => d)
    .catch(e => {
      console.log(e);
      throw new Error(e);
    });

最佳答案

我认为这不是您的代码或您网络一侧的问题,除非您同时遇到一般连接问题。

ip 169.45.89.179 解析为 sendgrid 的域,因此这可能是他们的问题,要仔细检查这一点,您可以设置对 8.8.8.8 的连续 ping 或运行其他一些网络监控设置以确保您的连接稳定。

如果您的连接不是问题,我会将其连同您准备共享的任何日志一起报告给他们,您的源 IP 和发生超时错误的时间可能对他们有用

关于node.js - sendgrid 使用 @sendgrid/mail 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54861659/

相关文章:

node.js - 使用 nodejs 和 node-mysql 返回行

javascript - Node .js fs.writeFile : err returns null

node.js - 如何在 Node js 中通过电子邮件附加 .ics 文件?

sendgrid - Return Path 或 SendGrid 这样的软件如何知道有多少电子邮件到达收件箱?

azure-functions - 创建 Sendgrid 帐户时部署验证失败

django - 在 Heroku 中使用 Sendgrid 为 Django 应用程序设置电子邮件

Node.js - 如何通过配置获取自定义环境变量?

mysql - 如何使用带有 FOREIGN KEY 的 SELECT 语句在带有 mysql 包的 Node.js 中插入 INTO

javascript - node.js 标准模块的全局变量?

php - 如何使用 SendGrid 发送电子邮件