试图用gunmail发送邮件,错误

时间:2016-06-02 01:14:36

标签: node.js express mailgun nodemailer

尝试跟随mailgun's nodejs tutorial,但我收到此错误:

error  { [Error: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server.</p><p>If you entered the URL manually please check your spelling and try again.</p>
] statusCode: 404 }
undefined

我在节点服务器中使用的代码如下所示:

var express = require("express");
var expressApp = express();
var server = http.createServer(expressApp);

//Port number for the server
var portNum = process.env.PORT || 80;

var Mailgun = require('mailgun-js');

//get requests
expressApp
    .get("/", function routeHandler(req, res) {
        res.sendFile(path.join(__dirname, "../client/index.html"));

        var api_key = 'key-00000000000000000000';
        var domain = "https://api.mailgun.net/v3/mydomain.com"; //I think the error must be here
        var mailgun = new Mailgun({apiKey: api_key, domain: domain});

        var data = {
            from: "me@mydomain.com", //I tried also with me@samples.mailgun.org which was in the example

            to: 'myemail@gmail.com',
            subject: 'Hello',
            text: 'Testing some Mailgun awesomness!'
        };

        mailgun.messages().send(data, function (err, body) {
            if (err) {
                console.log("error ", err);
            }

            console.log(body);
        });


    })

...

请帮助我被困这么多时间,没有那么多关于node.js + mailgun的文档

0 个答案:

没有答案