[英]Nodemailer - Works locally but not on production
https://gist.github.com/anonymous/ba82f74071cc38a0700b https://gist.github.com/anonymous/ba82f74071cc38a0700b
Before changing some settings, eg host and port, it was working fine locally, but just won't work on production.在更改某些设置(例如主机和端口)之前,它在本地工作正常,但在生产中无法正常工作。
Anyone know why?有谁知道为什么?
Thanks谢谢
Disable Captcha temporarily so you can mail using new server,暂时禁用验证码,以便您可以使用新服务器发送邮件,
https://accounts.google.com/b/0/displayunlockcaptcha https://accounts.google.com/b/0/displayunlockcaptcha
i think this is happening because of port number and your firewall at this port is not allowing you to send mail over this port(80) .我认为这是因为端口号和您在此端口上的防火墙不允许您通过此端口 (80) 发送邮件。 try with 587 or 465 which are actually the standard port number for SMTP.
尝试使用 587 或 465,它们实际上是 SMTP 的标准端口号。
changed your code a bit稍微改变了你的代码
/**
* Created by atul on 29/3/16.
*/
var nodemailer = require('nodemailer');
transporter = nodemailer.createTransport({
service: 'Gmail',
//host: 'myhost',
port: 465,
secure: true,
auth: {
user: 'mymail@gmail.com',
pass: 'mypassword'
}
});
mailOptions = {
from: 'mymail@gmail.com',
to: 'mymail@gmail.com',
subject: 'You received a new message at !',
text: 'Hello Mailer',
html: ''
};
transporter.sendMail(mailOptions, function(error, info){
if(error){
console.log(error)
}else{
console.log('Message sent: ' + info.response)
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.