【问题标题】:Got an error sending email with nodejs and mailgun使用 nodejs 和 mailgun 发送电子邮件时出错
【发布时间】:2020-04-21 22:10:16
【问题描述】:

之前有人说我在做一个重复的问题,我已经搜索过其他解决方案,对我来说不起作用,例如这个:Example of the domain name for mailgun be for nodejs?

我一直在尝试使用带有 nodejs + typescript 的 mailgun 的 api 发送电子邮件。 我已经安装了所有需要的库,事实上,如果我使用 mailgun 允许您使用的沙箱域,一切正常。 当我使用我在mailgun中添加的域时,问题就来了。 我的代码是这样的:

const mailer = new Mailgun({
        apiKey: api_key,
        domain: 'tresee.app'
    });
    const mensaje = {
        from: "tresee.app",
        to: "miguelmonteiroclaveri@gmail.com",
        subject: "Hello",
        html: "<b>Testing some Mailgun awesomeness!</b>"
    };
    const response = await mailer.messages().send(mensaje);

Este codigo, si pongo el dominio de sandbox de mailgun funciona perfectamente, pero si pongo mi dominio tresee.app me sale el siguiente error:

error Error: Domain not found: tresee.app
  at IncomingMessage.<anonymous> (C:\Users\migue\Documents\proyectoFinal\auth-backend\node_modules\mailgun-js\lib\request.js:327:17)
  at IncomingMessage.emit (events.js:323:22)
  at endReadableNT (_stream_readable.js:1204:12)
  at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  statusCode: 404
} 
body { message: 'Domain not found: tresee.app' }

在 mailgun 中,我使用下一个 dns 记录正确添加了我的域,但仍然给我错误

谁能解释我为什么会收到此错误消息?非常感谢你

【问题讨论】:

    标签: node.js typescript npm mailgun


    【解决方案1】:

    已解决,文档中的任何地方都是这个答案,只是幸运地找到了它。 必须在mailgun的初始化中添加下一行: host: "api.eu.mailgun.net"

    【讨论】:

      猜你喜欢
      • 2016-10-06
      • 2014-04-14
      • 1970-01-01
      • 2017-10-12
      • 1970-01-01
      • 2019-11-18
      • 2021-01-01
      • 2015-09-15
      • 2018-09-05
      相关资源
      最近更新 更多