如何解决Laravel电子邮件问题 [英] How to Fix Laravel Email Issue
本文介绍了如何解决Laravel电子邮件问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在实现Laravel 5.8内置的电子邮件验证功能,但不幸的是我找不到该错误.
I'm implementing Laravel 5.8 built-in Email Verification feature but unfortunately I couldn't figure the bug.
我在y User
模型中添加了MustVerifyEmail
接口.
I've added the MustVerifyEmail
interface in ,y User
Model.
这是我在Laravel中的.ENV
文件.与mail.php
中使用的配置相同.
This is my .ENV
file in Laravel. Same configuration I used in 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
推荐答案
用于在laravel中配置gmail设置,
For configuring gmail settings in laravel,
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your_email_address@gmail.com
MAIL_PASSWORD=your_gmail_address_password
MAIL_FROM_ADDRESS=your_email_address@gmail.com
MAIL_FROM_NAME="YOUR_USER_NAME"
MAIL_ENCRYPTION=tls
还要在mail.php中更新以下内容
Also update the following in mail.php
'pretend' => false,
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
要测试您的配置,请将此代码放在api.php上
To test your configuration put this code on api.php
Route::get('/emailTest',function(){
$emailData = [
'from' => 'admin_email@gmail.com',
'email' => 'user_email@gmail.com',
'password' => 'user_password',
];
// "mails.toUser" : this is my email template in resources
Mail::send('mails.toAdmin',['emailData' => $emailData],function($message) use ($emailData){
$message->to($emailData['email'])
->from($emailData['from'])
->subject('New User Registration');
});
});
这篇关于如何解决Laravel电子邮件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文