我正在开发一个NodeJS和ExpressJS项目,我需要使用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);
}
});
});
运行此代码时,出现错误:
{ statusCode :404
}