我正在使用laravel 5.6,问题我尝试在用户注册时发送电子邮件我收到了来自电子邮件发送功能的成功回复,但没有在我的收件箱中收到电子邮件,正在努力尝试更改smtp设置 我的config / mail.php看起来像。
return [
'driver' => env('MAIL_DRIVER', 'sendmail'),
'host' => env('MAIL_HOST', 'a2plcpnl0866.prod.iad2.secureserver.net'),
'port' => env('MAIL_PORT', 465),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'test@mydomain.com'),
'name' => env('MAIL_FROM_NAME', 'My Name'),
],
'encryption' => env('MAIL_ENCRYPTION', ''),
'username' => env('MAIL_USERNAME','test@mydomain.com'),
'password' => env('MAIL_PASSWORD','password'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
发送邮件代码。
public function sendVerificationMail(User $user)
{
$data = ['confirmation_code' => $user->confirmation_code,
'verifyLink' => route('confirm:register', $user->confirmation_code)
];
Mail::send('frontend.mail.verify-email', $data, function ($message) use ($user) {
$message->to($user->email)
->subject('Verify your email address');
});
}
.env文件
MAIL_DRIVER=sendmail
MAIL_HOST=a2plcpnl0866.prod.iad2.secureserver.net
MAIL_PORT=465
MAIL_USERNAME=test@mydomain.com
MAIL_PASSWORD=password