【问题标题】:Nodemailer - Works locally but not on productionNodemailer - 在本地工作,但不能在生产环境中工作
【发布时间】:2016-07-16 18:17:05
【问题描述】:

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

在更改某些设置之前,例如主机和端口,它在本地运行良好,但无法在生产环境中运行。

有人知道为什么吗?

谢谢

【问题讨论】:

  • 你的应用部署在哪里...??

标签: javascript node.js nodemailer


【解决方案1】:

暂时禁用验证码,以便您可以使用新服务器发送邮件,

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

【讨论】:

  • 哇,这让我免去了很多麻烦
  • 这是什么鬼??这在部署到 heroku 时也能救我
  • 如何使用其他 Google 帐户禁用?这会自动导致一个页面为我的主帐户禁用
  • @Atenean1 以隐身模式打开浏览器,使用您的辅助帐户(您无法解锁的帐户)登录,然后从上方打开链接。
【解决方案2】:

我认为这是由于端口号而发生的,并且您在此端口的防火墙不允许您通过此端口(80)发送邮件。尝试使用 587 或 465,它们实际上是 SMTP 的标准端口号。

稍微修改了代码

/**
 * 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)
}
});

【讨论】:

  • 我用的是app.listen(80),那不是我用的吗?
  • 你能写出你正在尝试的代码吗,因为从上面的代码中我只是知道你想创建一个错误的端口 80 上的传输
  • 刚刚尝试了 587 和 465,都没有成功._。代码是一样的,只是端口:587/465 而不是 80
  • 您是否检查过这些端口上没有防火墙,并且这些端口也已打开?
猜你喜欢
  • 2018-03-23
  • 2019-04-18
  • 2020-08-25
  • 2019-08-17
  • 1970-01-01
  • 1970-01-01
  • 2023-01-30
  • 2021-12-08
  • 2014-04-27
相关资源
最近更新 更多