nodemailer在AWS Ec2上的生产环境中导致错误 [英] nodemailer is causing an error in production environment on Aws Ec2
问题描述
我正在使用 node.js
使用 nodemailer
发送电子邮件,并且我具有此配置来发送电子邮件
I am sending emails using nodemailer
using node.js
and i have this configuration to send emails
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
};
它在本地环境中正确发送电子邮件,但在 AWS Ec2
上的生产环境中,它抛出此错误
It's sending emails on local environment correctly but in production environment on Aws Ec2
it is throwing this error
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
我在这样的 ec2
实例安全组中允许出站端口465
I allowed outbound port 465 in my ec2
instance security group like this
真正的问题是什么?
推荐答案
您可能需要Gmail的许可.
You may require permission for this from Gmail.
您必须为此启用允许访问您的Google帐户.
步骤:
- 通过与您尝试使用的浏览器相同的浏览器转到此链接登录.
- 它将询问允许访问您的Google帐户".点击继续"按钮.
- 将显示消息已启用帐户访问".
此外,还必须设置"Less Secure Apps".通过以下链接: https://myaccount.google.com/lesssecureapps .
Also, setting for "Less Secure Apps" must be allowed. Go through this link: https://myaccount.google.com/lesssecureapps.
如果问题仍然存在,请检查您的服务器IP是否被Gmail阻止.
If the issue still persists, check if your server IP is blocked by Gmail.
这应该有帮助!
这篇关于nodemailer在AWS Ec2上的生产环境中导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!