最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Nodemailer,Heroku,Gmail,无效登录

运维笔记admin7浏览0评论

Nodemailer,Heroku,Gmail,无效登录

Nodemailer,Heroku,Gmail,无效登录

我在过去几周一直遇到这个问题,它每次都在本地工作,但是一旦我将它部署到我的heroku服务器,它会给我一个invalid login错误。我已经进入帐户并且可以访问不太安全的应用程序。并且凭据是正确的,并且它每次都在localhost上工作。有什么我想念的吗?

quickSendMail: function(routeBody, callback) {
//configuring the nodemailer for email notifications
  var smtpConfig = {
          host: 'smtp.gmail',
          port: 465,
          secure: true, // use SSL
          auth: {
              user: 'mysmtpemail123',
              pass: '******'
            }
        };

  var mailOptions = {
          from: 'SageStorm Site <[email protected]>',
          to: ['my email'],
          subject: routeBody.subject,
          html: 'my message'
        };

  var transporter = nodemailer.createTransport(smtpConfig);

  transporter.verify(function(error, success) {
        if (error) {
                console.log(error);
        } else {
                console.log('server is ready to send emails');
          }
        })
  transporter.sendMail(mailOptions, function(error, info) {
        if (error) {
              console.log(error);
              return callback(err, null);
        } else {
              console.log('Message sent: ' + info.response);
              return callback(null, info);
          }
        })
    }
回答如下:

试试this,它将允许机器远程访问你的Gmail。

如果这不起作用,请尝试将您的nodemailer更新到最新版本。

发布评论

评论列表(0)

  1. 暂无评论