简体   繁体   English

Nodemailer - 在本地工作但不在生产中

[英]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.

相关问题 Nodemailer、Heroku、Gmail、无效登录 - 在本地工作 - Nodemailer, Heroku, Gmail, invalid login - works locally Nodemailer,在本地工作正常,但在我的服务器上不起作用 - Nodemailer, works fine locally but doesn't work on my server Heroku-特定路线在本地有效,但不适用于生产 - Heroku - specific route works locally but not on production React UseEffect 在本地工作,但在生产环境中不工作 Netlify - React UseEffect works locally but not In production Netlify Nodemailer 仅在生产中失败 - Nodemailer fails only in production 该 api 在生产中不起作用,它不会更新数据。 但如果它在本地工作 - The api does not work in production, it does not update the data. But if it works locally v-for 组件不在生产机器上渲染但在本地工作 - v-for components not rendering on production machine but works locally Express + React:CSRF Coo​​kie 在生产中未定义,在本地工作 - Express + React: CSRF Cookie is undefined in production, works locally NodeJS/Nodemailer 可以在本地使用nodemailer吗? 问题 - 从未收到问候 - NodeJS/Nodemailer Can use nodemailer locally? Problem - Greeting never received Javascript可在本地使用,但无法在生产环境中使用 - Javascript working locally but not on production
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM