Javascript nodeEmailer:ERR_CONNECTION_RESET with AngularJS和NodeJS with POST

Javascript nodeEmailer:ERR_CONNECTION_RESET with AngularJS和NodeJS with POST,javascript,node.js,angularjs,email,nodemailer,Javascript,Node.js,Angularjs,Email,Nodemailer,以下是我尝试使用post方法从AngularJS发送到NodeJS的post数据: $scope.doStuff = function(foo, bar) { $http({method: 'post', url: '/send', data: {foo: foo, bar: bar}}). success(function(data, status, headers, config) { console.log(data); }); };

以下是我尝试使用post方法从AngularJS发送到NodeJS的post数据:

$scope.doStuff = function(foo, bar) {
    $http({method: 'post', url: '/send', data: {foo: foo, bar: bar}}).
        success(function(data, status, headers, config) {
            console.log(data);
    });
};
下面是我如何使用NodeJS在服务器端接收数据:

 router.post('/send',function(req,res){

    var transporter = nodemailer.createTransport({
        service: 'Gmail',
        auth: {
            user: 'foobar@gmail.com',
            pass: 'foobar'
        }
    });
    var mailOptions = {
        from: 'Foo Bar ✔ <foobar@gmail.com>',
        to: req.body.foo, // list of receivers
        subject: "Hello FooBar", 
        text: 'Hello ' + req.body.foo,
        html: "<p>Hello FooBar, you rock!</p>"
    };
    transporter.sendMail(mailOptions, function(error, info){
        if(error){
            console.log(error);
        }else{
            console.log('Message sent: ' + info.response);
        }
    });
});
router.post('/send',函数(req,res){
var transporter=nodeEmailer.createTransport({
服务:“Gmail”,
认证:{
用户:'foobar@gmail.com',
传球:“foobar”
}
});
var mailpoptions={
来自:富吧✔ ',
收件人:req.body.foo,//收件人列表
主题:“你好,福巴”,
文本:“你好”+req.body.foo,
html:你好,福巴,你棒极了!

“ }; transporter.sendMail(邮件选项,函数(错误,信息){ 如果(错误){ console.log(错误); }否则{ console.log('发送的消息:'+信息响应); } }); });
我只是想用nodemailer发送电子邮件,我已经可以发送电子邮件了。 但是我得到了一个
帖子http://localhost:3000/send 发送请求后,请在控制台上执行ERR_CONNECTION_RESET
。 有时我也会收到
帖子http://localhost:3000/send net::控制台上的ERR_EMPTY_响应


有人能帮我理解为什么我会在控制台上看到它,以及如何解决它吗?

您不会从您的路线返回响应

res.send(200)

您不会从路线返回响应

res.send(200)

以前,当我使用
nodemailer
模块时,我也遇到了同样的问题。可能是服务器配置错误,因为代码在本地服务器上运行良好。在直播中,它会显示
错误:connect econnreference
。为了解决这个问题,我做了很多努力,但是没有成功。所以最后我切换到了另一个模块,即
它对我来说效果很好,你可以试试。

以前我在使用
nodemailer
模块时,也遇到过同样的问题。可能是服务器配置错误,因为代码在本地服务器上运行良好。在直播中,它会显示
错误:connect econnreference
。为了解决这个问题,我做了很多努力,但是没有成功。所以最后我切换到了另一个模块,即
它对我很有效,你可以试一试。

在支持NodeEmailer的情况下被去除了润滑脂。为了诺德梅勒的利益,他被抹黑了。