【发布时间】:2019-08-09 22:59:04
【问题描述】:
我目前在使用make:auth in Laravel 5.6 创建的密码重置邮件时遇到问题。我的应用程序托管在 Heroku 上。在我当地的环境中,一切正常。我在 Heroku 的配置变量中设置了正确的值,在我的本地 .env 文件中相同:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myMail@gmail.com
MAIL_PASSWORD=bla
MAIL_ENCRYPTION=tls
我在这里读到我必须对 app/mail.php 中的值进行硬编码,而不是引用 .env 文件,因为 Heroku 无法识别/理解此引用
'password' => env('MAIL_PASSWORD')
但是我的数据将在 GitHub 存储库中可见。
我在这里做错了什么?
编辑:
公认的答案是要走的路,应该使用附加组件在 Heroku 中发送邮件。在设置 sendgrid 之后,我仍然找到了一种让它与 gmail 一起使用的方法;)
- Use `Port 465 with ssl` as encryption.
- Allow `less secure apps` access to my account.
- Visit `http://www.google.com/accounts/DisplayUnlockCaptcha` and sign in with your Gmail username and password.
在这些步骤之后,它起作用了。 也许这对其他人有帮助。
EDIT2:
我将 Laravel 从 5.x 版迁移到 8 版,但又遇到了问题,所以我不得不再次使用 gmail 改变我的方法。
我不得不:
- Allow `less secure apps` access to my account.
- Enable two step verification and create an App Password like in the accepted answer of this question: https://stackoverflow.com/questions/42558903/expected-response-code-250-but-got-code-535-with-message-535-5-7-8-username
- Change Port back to 587 and tls again
- Visit `http://www.google.com/accounts/DisplayUnlockCaptcha` and sign in with your Gmail username and password.
【问题讨论】:
-
使用 getenv('ENV_VARIABLE') 可能会对您有所帮助。
-
您的解决方案有效,只需更改端口和加密类型。谢谢!
标签: laravel heroku laravel-5 laravel-8