vendredi 9 septembre 2016

Laravel 5.1 send email (Connection could not be established with host smtp.gmail.com [connection time out #110]

I'm learning Laravel 5.1 mail for my project. So, I try to send simple email first from a new Laravel 5.1 application on my localhost.

this is my .env config file

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=mygmail@gmail.com
MAIL_PASSWORD=mygmailpassword
MAIL_ENCRYPTION=tls

and this is my config/mail.php

'driver' => env('MAIL_DRIVER', 'smtp'),

'host' => env('MAIL_HOST', 'smtp.mailgun.org'),

'port' => env('MAIL_PORT', 587),

'from' => ['address' => 'sender@gmail.com', 'name' => 'Sender'],

'encryption' => env('MAIL_ENCRYPTION', 'tls'),

'username' => env('MAIL_USERNAME'),

'password' => env('MAIL_PASSWORD'),

'sendmail' => '/usr/sbin/sendmail -bs',

this is my function to send the email

Mail::send('emails.email', ['user'=>'Sender'], function($m){

    $m->to('receiver@yahoo.com','receiver')->subject('subject');
});

With this, when I run the application, it always return the error

Swift_TransportException in StreamBuffer.php line 265:

Connection could not be established with host smtp.gmail.com [Connection timed out #110]

What I've tried:

  • Turn on 'less secure apps' on google account
  • 2-step verification (generate an app password) and use it on (MAIL_PASSWORD on .env config)

But, none of this succeed. What am I doing wrong here?

PS: My OS is Linux Ubuntu 14.04



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire