Sending email using "mailgun" with nodejs with 404 error

I am working on a NodeJS and ExpressJS project where I need to use Mailgun.

app.get('/send', function (req, res) {
    var mailgun = new Mailgun({
        apiKey: api_key,
        domain: domain
    });

    var data = {
        from: frommail,
        to: 'im88@gmail.com',
        subject: 'Hello',
        text: 'Testing some Mailgun awesomness!'
    };

    mailgun.messages().send(data, function (err, body) {
        //If there is an error, render the error page
        if (err) {
            res.json(err);
            console.log("got an error: ", err);
        } else {

            res.json(data);
            console.log(body);
        }
    });

});

When I run this code, I get an error message:

{ statusCode :404

}
+4
source share

Source: https://habr.com/ru/post/1625618/


All Articles