mailgun / mailgun.js

Javascript SDK for Mailgun
https://www.npmjs.com/package/mailgun.js
Apache License 2.0
521 stars 110 forks source link

Example doesn't work #15

Closed rotexhawk closed 3 years ago

rotexhawk commented 7 years ago

I am trying to run the following example. Keep getting 404 error. I can send a message with curl using the same (my) credentials. Not sure what's going on. Thanks.

mg.messages.create('sandbox-123.mailgun.org', { from: "Excited User <mailgun@sandbox-123.mailgun.org>", to: ["test@example.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.log(err)); // logs any error

andrii-yelis commented 3 years ago

Hi @rotexhawk

I used it the next way and it works OK:

try {
    const res = await mg.messages.create(domain, {
      from: fromEmail,
      to: toEmail,
      cc: undefined,
      subject: 'Hello 3',
      // text: 'Testing some Mailgun awesomeness!',
      html: `
      <h1>Test email header</h1>
      <p>Test email body</p>
      `
      // attachment: [rackspaceLogo]
    });

    console.log(res);
  } catch (err) {
    console.error(err);
  }

Maybe you don't have such a domain in a region you use, could you check it, please?

andrii-yelis commented 3 years ago

I'm closing this one, if you still have such issue please open a new one.

lylest commented 2 years ago

Having 404