Nodemailer - Works locally but not on production

风格不统一 提交于 2019-12-06 05:15:02

问题


https://gist.github.com/anonymous/ba82f74071cc38a0700b

Before changing some settings, e.g. host and port, it was working fine locally, but just won't work on production.

Anyone know why?

Thanks


回答1:


Disable Captcha temporarily so you can mail using new server,

https://accounts.google.com/b/0/displayunlockcaptcha




回答2:


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) . try with 587 or 465 which are actually the standard port number for 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)
}
});


来源:https://stackoverflow.com/questions/36280121/nodemailer-works-locally-but-not-on-production

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!