如何修复 Laravel 电子邮件问题

我正在实施 Laravel 5.8 内置电子邮件验证功能,但不幸的是我无法弄清楚错误。


我已经MustVerifyEmail在 ,yUser模型中添加了接口。


这是我.ENV在 Laravel 中的文件。我在mail.php.


.env


MAIL_DRIVER=smtp

MAIL_HOST=smtp.gmail.com

MAIL_PORT=465

MAIL_USERNAME="<My user Name>"

MAIL_PASSWORD="<My Password>"

MAIL_ENCRYPTION=ssl

http://img2.mukewang.com/61d197cf0001b1ab07300415.jpg

胡子哥哥
浏览 150回答 2
2回答

噜噜哒

您必须在 Google 帐户安全设置中启用对安全性较低的应用程序的访问权限。

桃花长相依

要在 Laravel 中配置 gmail 设置,MAIL_DRIVER=sendmailMAIL_HOST=smtp.gmail.comMAIL_PORT=587MAIL_USERNAME=your_email_address@gmail.comMAIL_PASSWORD=your_gmail_address_passwordMAIL_FROM_ADDRESS=your_email_address@gmail.comMAIL_FROM_NAME="YOUR_USER_NAME"MAIL_ENCRYPTION=tls还要更新mail.php中的以下内容'pretend' => false,&nbsp; &nbsp; 'stream' => [&nbsp; &nbsp; &nbsp; &nbsp; 'ssl' => [&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'allow_self_signed' => true,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'verify_peer' => false,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'verify_peer_name' => false,&nbsp; &nbsp; &nbsp; &nbsp; ],&nbsp; &nbsp; ],要测试您的配置,请将此代码放在 api.php 上Route::get('/emailTest',function(){&nbsp; &nbsp; $emailData = [&nbsp; &nbsp; &nbsp; &nbsp; 'from'&nbsp; &nbsp; &nbsp; => 'admin_email@gmail.com',&nbsp; &nbsp; &nbsp; &nbsp; 'email'&nbsp; &nbsp; &nbsp;=> 'user_email@gmail.com',&nbsp; &nbsp; &nbsp; &nbsp; 'password'&nbsp; => 'user_password',&nbsp; &nbsp; ];&nbsp; &nbsp; // "mails.toUser" : this is my email template in resources&nbsp; &nbsp; Mail::send('mails.toAdmin',['emailData' => $emailData],function($message) use ($emailData){&nbsp; &nbsp; &nbsp; &nbsp; $message->to($emailData['email'])&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ->from($emailData['from'])&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ->subject('New User Registration');&nbsp; &nbsp; });});
打开App,查看更多内容
随时随地看视频慕课网APP