0

I tried running this code from their npmjs documentation.

const mailgun = new Mailgun(FormData);
const mg = mailgun.client({ username: 'api', key: MY_MAILGUN_API, url: 'https://api.eu.mailgun.net'})
mg.messages.create('sandbox-123.mailgun.org', {
      from: "Excited User <mailgun@sandbox-123.mailgun.org>",
      to: ["myrealemail@gmail.com"],
      subject: "Hello",
      text: "Testing some Mailgun awesomness!",
      html: "<h1>Testing some Mailgun awesomness!</h1>"
    })
 .then(msg => console.log(msg)) // logs response data
 .catch(err => console.error(err)); // logs any error

and it throws error

[Error: Unauthorized] {
  status: 401,
  details: 'Forbidden',
  type: 'MailgunAPIError'
}

and i have no idea where the problem is. googled and nothing relevant comes up for me.

MY_MAILGUN_API - copied from my account

myrealmail@gmail.com - in code i have email that i can access

Tadas V.
  • 775
  • 1
  • 11
  • 22

0 Answers0