Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -


i developing website contact-us page guest users can send me email using gmail. anytime try send mail using contact-us form, error swift_transportexception in streambuffer.php line 269: connection not established host smtp.gmail.com [ #0]

this mail.php

 return [     'driver' => env('mail_driver', 'smtp'),     'host' => env('mail_host', 'smtp.gmail.com'),     'port' => 587,     'from' => ['address' => '', 'name' => ''],     'encryption' => env('mail_encryption', 'tls'),     'username' => env('mail_username'),     'password' => env(mail_password),     'sendmail' => '/usr/sbin/sendmail -bs',     'pretend' => env('mail_pretend', false),   ]; 

this .env

  mail_driver=smtp   mail_host=smtp.gmail.com   mail_port=587   mail_username=afecjaped@gmail.com   mail_password=********   mail_encryption=tls 

this usercontroller.php

 public function sendmail() {     $input = request::all();      $data = [       'name' => $input['name'],       'email' => $input['email'],       'subject' => $input['subject'],       'message' => $input['message']     ];      $rules = user::$mailrules;      $validator = validator::make($input, $rules);     if ($validator->fails()) {       return redirect()->back()->witherrors($validator)->withinput($input);     } else {       mail::send('emails.send', $data, function($message) use ($data) {         $message->from(input::get('email'))                 ->to('afecjaped@gmail.com')                 ->subject(input::get('subject'));       });     return 'email sent';     } } 

you have configure gmail account use smtp accounts.google.com. check enter link description here guide


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

c# SetCompatibleTextRenderingDefault must be called before the first -