{[错误:连接超时]代码:' ETIMEDOUT'在nodemailer中

时间:2016-06-14 20:49:50

标签: node.js smtp cloud9-ide nodemailer

我在cloud9的node.js应用程序中使用nodemailer模块时遇到了一些问题。我的代码的简化版本是

      mail_test : function(req, res, next){
var nodemailer = require("nodemailer");
var smtpTransport = require('nodemailer-smtp-transport');

var transport = nodemailer.createTransport(smtpTransport({
    host : "smtp.webfaction.com",
    secureConnection : true,
    port: 465,
    auth : {
        user : "username",
        pass : "password"
    }
}));

    var mailOptions={
        from : "info@feedcourt.com",
        to : "net.nayek@gmail.com",
        subject : "Your Subject",
        text : "Your Text",
/*        html : "<b>HTML GENERATED</b>",
        attachments : [
            {   // file on disk as an attachment
                filename: 'text3.txt',
                path: 'Your File path' // stream this file
            }
        ]*/
    }

    transport.sendMail(mailOptions, function(error, response){
        if(error){
            console.log(error);
            res.end("error");
        }else{
            console.log(response.response.toString());
            console.log("Message sent: " + response.message);
            res.end("sent");
        }
    });
  },

当我尝试在服务器上执行它时,我收到了ETIMEDOUT错误

{ [Error: Connection timeout] code: 'ETIMEDOUT' }

我的模块版本是 -

"nodemailer": "^2.4.2"
    "nodemailer-smtp-transport": "^2.5.0"

我非常沮丧。请帮帮我

1 个答案:

答案 0 :(得分:1)

不允许从cloud9工作区发送电子邮件阻止垃圾邮件。 有关详细信息,请参阅https://community.c9.io/t/how-can-i-send-email-from-my-app/1262/3