我想使用driver: smtp
和host: smtp.gmail.com
从laravel 5中的本地主机发送电子邮件
这是我在成功开户后发送电子邮件的示例代码。
public function postRegister(Request $request)
{
$password = PropertyHelper::randomPassword();
$arrUser = [
'_token' => $request->input('_token'),
'name' => $request->input('name'),
'mobile' => $request->input('mobile'),
'email' => $request->input('email'),
'password' => $password,
'password_confirmation' => $password
];
$validator = $this->registrar->validator($arrUser);
if ($validator->fails())
{
$this->throwValidationException(
$request, $validator
);
}
$data = [
'name' => $request->input('name'),
'password' => $password,
'email' => $request->input('email'),
];
$this->auth->login($this->registrar->create($arrUser));
$data = [
'name' => $request->input('name'),
'password' => $password,
];
$emailSend = Mail::send('emails.signup', $data, function($message){
$message->to(Auth::user()->email)
->subject('নতুন একাউন্ট');
});
dd($emailSend); //output 1
if($emailSend)
{
return redirect($this->redirectPath());
}
}
这是我的config / mail.php文件
return [
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'from' => ['address' => 'hizbul25@gmail.com', 'name' => 'Admin'],
'encryption' => 'tls',
'username' => 'myEmail@gmail.com',
'password' => 'gmailPassword',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
此代码未显示任何错误,但也未发送电子邮件。如果我尝试打印出电子邮件发送它说1.任何想法,请?
答案 0 :(得分:0)
尝试更改根文件夹下的.inv内的邮件信息而不是mail.php作为以前版本的laravel