MailGun results in 401 forbidden using nodeJs

62
December 01, 2020, at 11:30 PM

I am trying to send an email using mailgun and nodejs. I took the code MailGun provides you and added my domain name and api key:

const mailgun = require('mailgun-js');
const DOMAIN = 'mail.mywebsite.com';
const mg = mailgun({apiKey: "this-is-myApiKey", domain: DOMAIN});
const data = {
    from: 'Support <support@mywebsite.com>',
    to: 'myemail@gmail.com',
    subject: 'Hello',
    text: 'Testing some Mailgun awesomness!'
};
mg.messages().send(data, function (error, body) {
    console.log(1, error);
    console.log(2, body);
});

This results in a 401 forbidden, but if I change to my sandbox domain name, then it works. Does anyone have some helpful tips to fix this?

mail.mywebsite.com = domain name set under sending domains
this-is-myApiKey = my private api key found here: https://app.mailgun.com/app/account/security/api_keys
READ ALSO
Do something if product type is changed

Do something if product type is changed

I have a custom WooCommerce product typeIf you switched between the standard WooCommerce type the input are cleared but this does not work for custom types

72
Why IntelliJ has inspections for generic usage disabled by default?

Why IntelliJ has inspections for generic usage disabled by default?

Why does IntelliJ has inspections for generic usage disabled by default?

72
Dynamically check value and display alarm popover

Dynamically check value and display alarm popover

I want to validate user input so he only provides numbers from a certain range with 0,5 stepsBut I want my website to do it every time user swaps to another input form, not after he sends the data to my view

36