我使用的是laravel 5.4,对于邮件,我使用邮件驱动程序来托管服务器邮件。
MAIL_DRIVER=mail
MAIL_HOST=mail.xxx.com
MAIL_PORT=465
MAIL_USERNAME=noreply@xxx.com
MAIL_PASSWORD=xxx
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=noreply@xxx.com
MAIL_FROM_NAME=xxx
在本地使用此配置不发送电子邮件,而是在服务器中发送。为什么?
我尝试邮件配置的所有选项,但不发送。
MAIL_DRIVER=smtp
MAIL_HOST=mail.xxx.com
MAIL_PORT=465
MAIL_USERNAME=noreply@xxx.com
MAIL_PASSWORD=xxx
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=noreply@xxx.com
MAIL_FROM_NAME=xxx
MAIL_DRIVER=smtp
MAIL_HOST=mail.xxx.com
MAIL_PORT=587
MAIL_USERNAME=noreply@xxx.com
MAIL_PASSWORD=xxx
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=noreply@xxx.com
MAIL_FROM_NAME=xxx
MAIL_DRIVER=smtp
MAIL_HOST=mail.xxx.com
MAIL_PORT=587
MAIL_USERNAME=noreply@xxx.com
MAIL_PASSWORD=xxx
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@xxx.com
MAIL_FROM_NAME=xxx
MAIL_DRIVER=mail
MAIL_HOST=mail.xxx.com
MAIL_PORT=587
MAIL_USERNAME=noreply@xxx.com
MAIL_PASSWORD=xxx
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@xxx.com
MAIL_FROM_NAME=xxx
它们不起作用。我如何从本地发送电子邮件?
答案 0 :(得分:0)
配置 Gmail的步骤:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail@gmail.com
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=xxx@gmail.com
MAIL_FROM_NAME=xxx
有关应用程序密码,请阅读第How to generate an App password:节下的内容 您可能无法为less secure apps创建应用密码。
配置邮件陷阱的步骤:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=from@example.com
MAIL_FROM_NAME=xxx
有关用户名和密码,请转到收件箱页面:https://mailtrap.io/inboxes单击“演示收件箱”链接,您将看到用户名和密码将如下所示:"username" => "b8f25cb615a7b3", "password" => "8218789886905f",
复制此用户名和密码并在配置中进行设置
完成.env
编辑后,不要忘记清除缓存:php artisan config:cache