mmonteirocl
mmonteirocl

Reputation: 479

Got an error sending email with nodejs and mailgun


Beofre someone say that I'm doing a duplicate question, i already searched and other solutions, for me doesn't work, per example this one: Example of the domain name for mailgun be for nodejs?

I have been trying to send a email with the api of mailgun with nodejs + typescript. I've instaled all the libraries needed, in fact everything works if I use the sandbox domain that mailgun let you use. The problem comes when i use the domain i have added in mailgun. My code is this:

const mailer = new Mailgun({
        apiKey: api_key,
        domain: 'tresee.app'
    });
    const mensaje = {
        from: "tresee.app",
        to: "[email protected]",
        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' }

In mailgun i added correctly my domain with the next dns records and still giving me the error image of domain verified

Image of all dns records asked and verified

Anyone can explain me why i get this error message ? Thank you so so much

Upvotes: 1

Views: 906

Answers (1)

mmonteirocl
mmonteirocl

Reputation: 479

Solved, anywhere in the documentation was this answer, just found it by luck. Had to add the next line in the inizialization of mailgun: host: "api.eu.mailgun.net"

Upvotes: 1

Related Questions