简体   繁体   English

nodemailer 在 Aws Ec2 上的生产环境中导致错误

[英]nodemailer is causing an error in production environment on Aws Ec2

I am sending emails using nodemailer using node.js and i have this configuration to send emails我正在使用node.js使用nodemailer发送电子邮件,我有这个配置来发送电子邮件

var transporter = nodemailer.createTransport({
            service: 'gmail',
            host: 'smtp.gmail.com',
            auth: {
                user: 'myemail@gmail.com',
                pass: 'password'
            }
        });
 const mailOptions = {
            from: 'myemail@gmail.com', // sender address
            to: user.company_email, // list of receivers
            subject: 'EnStream New Account Signup Password', // Subject line
            html: `<p style="font-size : 15px;">Please sing in to your en-stream account here <a href="http://demo.en-stream.com/auth/login">http://demo.en-stream.com/auth/login</a> with this password : ${userPassword}</p>`// plain text body
        };

It's sending emails on local environment correctly but in production environment on Aws Ec2 it is throwing this error它在本地环境中正确发送电子邮件,但在Aws Ec2的生产环境中它抛出此错误

code: "EAUTH"
command: "AUTH PLAIN"
response: "534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbua↵534-5.7.14 qup7zOOL4GtmYEf1HEHBASSSBgbuMNJRQqK2v3X9mcxDRX1SrXU2Y_LSqZm7Y7yJvH2PwL↵534-5.7.14 JZW6iSXxsRhBdntFAAamrvitpdKS_YJiE-pEnXWakITAz1PAzwDMxjJPKntQrLl2Qx-xA1↵534-5.7.14 zZ4aTvKvYOAk85YHwABnnd0wHU2HkUeHPoDYqgXUWgSA_8Rrn4xkIsUN> Please log↵534-5.7.14 in via your web browser and then try again.↵534-5.7.14  Learn more at↵534 5.7.14  https://support.google.com/mail/answer/78754 a11sm34494120wrx.5 - gsmtp"
responseCode: 534

I allowed outbound port 465 in my ec2 instance security group like this我像这样在我的ec2实例安全组中允许出站端口 465

在此处输入图像描述

What's the real issue in this?这里面真正的问题是什么?

You may require permission for this from Gmail.您可能需要获得 Gmail 的许可。

For which you have to enable the Allow access to your Google Account .为此,您必须启用Allow access to your Google Account

Steps:脚步:

  1. Go to this link through the same browser from which you are trying to Login.通过您尝试登录的同一浏览器转到此链接。
  2. It will ask "Allow access to your Google Account".它会询问“允许访问您的 Google 帐户”。 Click on "Continue" button.单击“继续”按钮。
  3. The message "Account access enabled" will be displayed.将显示消息“帐户访问已启用”。

Also, setting for "Less Secure Apps" must be allowed.此外,必须允许设置“不太安全的应用程序”。 Go through this link: https://myaccount.google.com/lesssecureapps .通过此链接: https ://myaccount.google.com/lesssecureapps。

If the issue still persists, check if your server IP is blocked by Gmail.如果问题仍然存在,请检查您的服务器 IP 是否被 Gmail 阻止。

This should help!这应该有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM