我一次又一次嘗試測試從本地主機發(fā)送電子郵件,但我仍然不能。我不知道該怎么做。我嘗試搜索以找到解決方案,但找不到。我編輯了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 回答

互換的青春
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 關注
- 1012 瀏覽
添加回答
舉報
0/150
提交
取消