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

送分小仙女□ 提交于 2019-12-04 19:22:02

问题


I can't sent out any email in my local environment.

I keep getting :

_

.env file.

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=my-email@gmail.com
MAIL_PASSWORD=*****

Note : Surprisingly - I have the same setting in my production server, and it works perfectly.

Any hints / suggestions ?


回答1:


Update my driver line to

MAIL_DRIVER=sendmail

It works on the first try.

Final .env file should look like this

MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=my-email@gmail.com
MAIL_PASSWORD=*****



回答2:


For me the following worked with GMAIL:

'encryption' => 'ssl',

.env

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=xxx@gmail.com
MAIL_PASSWORD=xxx



回答3:


1: Either you must allow less secure apps or use app password by enabling 2 step verification on your gmail acc. 2: Disable any antivirus on your machine.




回答4:


Change setting in .env file and keep your mail server's credentials after setup of smtp

MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=465 MAIL_USERNAME=xxx MAIL_PASSWORD=xxx




回答5:


Laravel also includes drivers for the Mailgun and Mandrill HTTP APIs. These APIs are often simpler and quicker than the SMTP servers. Both of these drivers require that the Guzzle 5 HTTP library be installed into your application. You can add Guzzle 5 to your project by adding the following line to your composer.json file:

"guzzlehttp/guzzle": "~5.0"

composer update

Mailgun Driver

To use the Mailgun driver, set the driver option to mailgun in your config/mail.php configuration file. Next, create an config/services.php configuration file if one does not already exist for your project. Verify that it contains the following options:

'mailgun' => [
    'domain' => 'your-mailgun-domain',
    'secret' => 'your-mailgun-key',
],

Mandrill Driver

To use the Mandrill driver, set the driver option to mandrill in your config/mail.php configuration file. Next, create an config/services.php configuration file if one does not already exist for your project. Verify that it contains the following options:

'mandrill' => [
    'secret' => 'your-mandrill-key',
],

Basic Usage

The Mail::send method may be used to send an e-mail message:

Mail::send('emails.welcome', ['key' => 'value'], function($message)
{
    $message->to('foo@example.com', 'John Smith')->subject('Welcome!');
});

http://laravel.com/docs/5.0/mail



来源:https://stackoverflow.com/questions/30624194/connection-could-not-be-established-with-host-smtp-gmail-com-operation-timed-ou

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!