我一次又一次尝试测试从本地主机发送电子邮件,但我仍然不能。我不知道该怎么做。我尝试搜索以找到解决方案,但找不到。我编辑了config / mail.php:<?phpreturn [ /* |-------------------------------------------------------------------------- | Mail Driver |-------------------------------------------------------------------------- | | Laravel supports both SMTP and PHP's "mail" function as drivers for the | sending of e-mail. You may specify which one you're using throughout | your application here. By default, Laravel is setup for SMTP mail. | | Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "ses", "log" | */ 'driver' => env('MAIL_DRIVER', 'smtp'), /* |-------------------------------------------------------------------------- | SMTP Host Address |-------------------------------------------------------------------------- | | Here you may provide the host address of the SMTP server used by your | applications. A default option is provided that is compatible with | the Mailgun mail service which will provide reliable deliveries. | */ 'host' => env('MAIL_HOST', 'smtp.gmail.com'), /* |-------------------------------------------------------------------------- | SMTP Host Port |-------------------------------------------------------------------------- | | This is the SMTP port used by your application to deliver e-mails to | users of the application. Like the host we have set this value to | stay compatible with the Mailgun e-mail application by default. | */ 'port' => env('MAIL_PORT', 587),];`
3 回答
![?](http://img1.sycdn.imooc.com/533e4c0500010c7602000200-100-100.jpg)
互换的青春
TA贡献1797条经验 获得超6个赞
首先登录到您的gmail帐户,并在My account > Sign In And Security > Sign In to google,下启用two step verification,然后可以生成app password,然后可以在.env文件中使用该应用密码。
您的.env文件将如下所示
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail@gmail.com
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls
php artisan config:cache在.env文件中进行更改后,请不要忘记运行。
- 3 回答
- 0 关注
- 1000 浏览
添加回答
举报
0/150
提交
取消