mercredi 3 juin 2020

Getting Error in Mail Send Using Gsuite in Laravel?

I am trying to send mail using Google Gsuite and i have read all the instruction, but i am getting Failed to authenticate on SMTP server with username error. Please let me know what is the mistake.

here are mu .env code...

MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=587
MAIL_USERNAME=sainiankit@gmail.com
MAIL_PASSWORD=vlwpadvjhygfrthu
MAIL_ENCRYPTION=ssl

here are my web.php file..

Route::post('postEmail','HomeController@postEmail');

here are my HomeControler.php file...

    public function postEmail(Request $r)
   {
$to_name = 'Mail from Ankit';
$to_email = 'sainiankit@gmail.com';
$data=[
    'user_email'=>$r->user_email,
    'user_name'=>$r->user_name,
    'user_phone'=>$r->user_phone,

];
Mail::send('mail', $data, function($message) use ($to_name, $to_email)
{
    $message->to($to_email, $to_name)->subject('Laravel Test Mail');;
    $message->from('sainiankit@gmail.com', 'Email Form Ankit');
});
return redirect()->back()->with('message','You are welcome.');

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire