发送电子邮件在本地有效,但一旦部署就不行?

Sending email works locally but not once deployed?

我有一个 meteor 应用程序,它使用 email and passwords 包来处理基本的密码重置功能。

在我的本地机器上,我将 MAIL_URL 环境变量设置为:

smtps://{user}:{password}@smtp.gmail.com:465

在对相关的 gmail 帐户进行一些调整后(我不得不 allow less secure applications),它起作用了。

我的实时环境是 heroku,所以我在那里设置了 env 变量:

heroku config:set MAIL_URL=smtps://{user}:{password}@smtp.gmail.com:465

然后确认是用heroku config设置的。但出于某种原因,当我尝试在我的生产环境中重置密码时,它会抛出以下错误:

Exception while invoking method 'forgotPassword' Error: Invalid login: 534-5.7.14

我什至做了 heroku restart 以绝对确定环境变量已被拾取,但我仍然收到错误。奇怪的是,这与我在启用 "Less secure apps" 之前遇到的错误相同。

谁能看出为什么会发生这种情况?关于如何修复它的建议?

在 Heroku 网络中,您的盒子上的设置/配置变量中,您真的看到了这个设置吗?

我发现您的问题可能是由于未确认验证码造成的...检查一下:Nodemailer with Gmail and NodeJS