i want to send an email to forgot password function congaing new password. Here is my code,
MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=offrs
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
here is my function for sending mail
public function sendMail(Request $request){
$new_key = str_random(10);
$data = array();
$data['email'] = $request->email;
$data['key'] = $new_key;
$checkUser = User::where('email','=',$request->email)->first();
if($checkUser == null){
return redirect()->back()->with('error','No User with this email exists in our record');
}
else{
Mail::send('mail.forgetPasswordMail', ['data' => $data], function ($message) use ($data) {
$message->from('raiafaculty@domain.com', 'RAIA Admin');
$message->to(Input::get('email'))->subject('Your New Password');
});
// $useremail = $request->get('email');
// $user = User::where('email', '=', $useremail)->first();
$checkUser->password = bcrypt($new_key);
$checkUser->save();
return redirect()->route('login')->with('success','Please Check Your email for new password');
}
}
it produces the error always. (1/1) Swift_TransportException Connection could not be established with host smtp.sendgrid.net [No connection could be made because the target machine actively refused it.
10061]
at Swift_Transport_StreamBuffer->initialize(array('protocol' => 'tcp', 'host' => 'smtp.sendgrid.net', 'port' => 587, 'timeout' => 30, 'blocking' => 1, 'tls' => true, 'type' => 1, 'stream_context_options' => array())) in AbstractSmtpTransport.php (line 113)
Help will be appreciated please.
在下面更改您的代码
MAIL_ENCRYPTION=null
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.