2013-02-15 732 views
1

我尝试发送电子邮件与EmailJS快递模块,但它只能在本地工作,它不能在远程工作(AppFog)...我不明白这个问题...发送电子邮件与快递和EmailJS

var email = require("emailjs"); 

var server = email.server.connect({ 
    user: "******", 
    password: "******", 
    host: "smtp.gmail.com", 
    ssl: true 
}); 

var send = function(message, from, subject) { 
    server.send({ 
     text: message, 
     from: from, 
     to:  "******** <*********>", 
     subject: subject 
    }); 
} 

exports.index = function(req, res) { 
    res.render('contact', { 
     emailSuccess: false, 
     title: "my title" 
    }); 
} 

exports.send = function(req, res) { 
    send(req.body.message, req.body.from, req.body.subject); 
    res.render('contact', { 
     emailSuccess: true, 
     title: "my title" 
    }); 
} 

回答

2

AppFog阻止SMTP传出请求以防止垃圾邮件。

你需要使用一个服务,如Sendgrid,亚马逊SES,邮戳等..

+0

好的,什么是最好的免费的吗? – tonymx227 2013-02-15 23:57:46

+0

真的不能保证哪一个最好,只有少数人拥有免费的开发者账户。我已经使用了Sendgrid(但我不确定他们是否有直接的免费计划,但他们通过heroku提供了一个)。如果您从EC2实例发送Amazon SES有一个免费计划(如果您在AppFog上使用EC2托管实例,则可以运行该计划)。 – 2013-02-16 00:03:58

+0

好的谢谢。亚马逊SES对我来说听起来不错。 – tonymx227 2013-02-16 00:12:18