gpt4 book ai didi

node.js - ec2 node.js 服务器不发送电子邮件 - 有什么想法吗?

转载 作者:太空宇宙 更新时间:2023-11-03 23:34:19 25 4
gpt4 key购买 nike

我有一个网站,在关闭一年多后正在恢复。我没有进行任何代码更改,并且我已经备份了网站,除了发送电子邮件的网站/应用程序之外,一切都像以前一样工作。

这是一个 ubuntu Node.js 服务器。它托管在 Amazon 上,我必须创建另一个实例并重新指向 dns 等。示例代码片段过去可以工作,但现在不行:

var emailServer  = email.server.connect({user:"<my gmail>",password:"<mypw>",host:"smtp.gmail.com",ssl:true});
emailServer.send({
text: "Your username is: " + userName + ".",
to: emailAddress,
subject: "Activate Your a2zCribbage Account",
attachment: [...]
}, function(err, message) { if (err) console.log(err); });

当我第一次尝试发送电子邮件时,我使用的 Gmail 帐户收到一条消息“登录尝试被阻止”有人刚刚尝试从不符合现代安全标准的应用登录您的 Google 帐户

我按照 Google 的说法更改了安全性以允许应用程序,但仍然没有发送任何内容。

我错过了什么?我还可以尝试哪些其他事情? ec2 服务器默认只允许发送电子邮件吗?

最佳答案

Gmail is not a platform for sending automated email.仅仅因为您可以并不意味着它就是为此而设计的。

AWS EC2 instances are also problematic for sending email ;端口可能被阻止或 throttled ,这样做肯定会获得更高的垃圾邮件分数。

规范的解决方案是使用 AWS SESHere's sample codehere's the documentation 。还有a simple third-party library .

关于node.js - ec2 node.js 服务器不发送电子邮件 - 有什么想法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34458974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com