2 回答
TA贡献1860条经验 获得超8个赞
要在 Laravel 中配置 gmail 设置,
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中的以下内容
'pretend' => false,
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
要测试您的配置,请将此代码放在 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');
});
});
- 2 回答
- 0 关注
- 149 浏览
添加回答
举报