简体   繁体   English

通过Laravel使用gmail smtp:[连接超时#110]

[英]Using gmail smtp via Laravel: [Connection timed out #110]

Before doing down vote or making it duplicate, please read the description . 在进行投票或复制之前,请阅读说明

I know this question is asked many times and have different solutions and I have tried all but no one has worked. 我知道这个问题被多次询问并且有不同的解决方案,我已经尝试了所有但没有人工作过。 This is my settings. 这是我的设置。

 MAIL_DRIVER=smtp
 MAIL_HOST=smtp.gmail.com
 MAIL_PORT=465
 MAIL_USERNAME=abc@mydomain.com
 MAIL_PASSWORD=mypassword
 MAIL_ENCRYPTION=ssl

And application is currently running on Centos 7 OS. 目前,应用程序正在Centos 7 OS上运行。

I always get 我总是得到

Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [Connection timed out #110]

at Swift_Transport_StreamBuffer->initialize(array('protocol' => 'ssl', 'host' => 'smtp.gmail.com', 'port' => '465', 'timeout' => '30', 'blocking' => '1', 'tls' => false, 'type' => '1', 'stream_context_options' => array())) in AbstractSmtpTransport.php line 113

I have tried all solutions, by Replacing: smtp.gmail.com with 173.194.65.108 , or replacing smtp.gmail.com by gmail-smtp-msa.l.google.com . 我尝试了所有解决方案,通过替换: smtp.gmail.com with 173.194.65.108 ,或者用smtp.gmail.com by gmail-smtp-msa.l.google.com替换smtp.gmail.com by gmail-smtp-msa.l.google.com When I do these two steps, it got server not found error. 当我执行这两个步骤时,它找不到服务器错误。

If I change mail driver from smtp to sendmail or mail , no error is thrown but no email is sent. 如果我将邮件驱动程序从smtp to sendmail or mail更改smtp to sendmail or mail ,则不会抛出任何错误,但不会发送电子邮件。

If I use ip address of smtp.gmail.com, I got same result. 如果我使用smtp.gmail.com的ip地址,我得到了相同的结果。 If I change port from 465 to 587 and encryption from ssl to tls , nothing happens. 如果我将端口从465 to 587更改465 to 587并从ssl to tls加密ssl to tls ,则没有任何反应。

I have also created a file in etc/gai.conf and put precedence ::ffff:0:0/96 100 . 我还在etc/gai.conf创建了一个文件并输出precedence ::ffff:0:0/96 100 It worked one time. 它工作了一次。 But later after two hours, it stopped working and started throwing same error. 但是两个小时后,它停止工作并开始抛出相同的错误。

I have also tried using my gmail id but all in vain. 我也试过使用我的gmail id,但都是徒劳的。

The only solution that I couldn't be able to test is verifying httpd_can_sendmail as whenever I run command getsebool httpd_can_sendmail I get getsebool: SELinux is disabled . 我无法测试的唯一解决方案是验证httpd_can_sendmail因为每当我运行命令getsebool httpd_can_sendmail我得到getsebool: SELinux is disabled Is this the problem or is there any other way to get it fixed? 这是问题还是有其他方法来解决它?

Here is my working mail config file: 这是我的工作邮件配置文件:

return [
    'driver' => 'smtp',
    'host' => 'smtp.gmail.com',
    'port' => 587,
    'from' => ['address' => '*******@gmail.com', 'name' => '****'],
    'encryption' => 'tls',
    'username' => '*******@gmail.com',
    'password' => '*******',
    'sendmail' => '/usr/sbin/sendmail -bs',
];

but from your question i can see you already tried all this, so i can assume it is a network problem based on error 'connection time out', what i mean is that something is blocking your connection, it might be your firewall if you have. 但从你的问题我可以看到你已经尝试了所有这些,所以我可以假设这是一个基于错误'连接超时'的网络问题,我的意思是有什么东西阻止你的连接,它可能是你的防火墙,如果你有。

so first you should check that the port 587 is open, or you can check if other application can connect with smtp.gmail.com (don't know how to do it in centOs). 所以首先你应该检查端口587是否打开,或者你可以检查其他应用程序是否可以与smtp.gmail.com连接(不知道如何在centOs中进行)。

And at last this might not be a problem but you have to enable 'Allow less secure apps' in your google account just for testing. 最后这可能不是问题,但您必须在Google帐户中启用“允许安全性较低的应用”才能进行测试。 (This is not permanent solution but for testing, if it works then you should enable two step verification in google account and then create new application, you can create new special password which you can use as your password for smtp server) (这不是永久解决方案,但是对于测试,如果它有效,那么你应该在谷歌帐户中启用两步验证然后创建新的应用程序,你可以创建新的特殊密码,你可以使用它作为smtp服务器的密码)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在laravel 5.2中与主机smtp.gmail.com建立连接[连接超时#110] - Connection could not be established with host smtp.gmail.com [Connection timed out #110] in laravel 5.2 PHPMailer SMTP无法连接到服务器:连接超时(110)到Gmail - PHPMailer SMTP Failed to connect to server: Connection timed out (110) to Gmail Swift_TransportException无法与主机smtp.gmail.com建立连接[连接超时#110] - Swift_TransportException Connection could not be established with host smtp.gmail.com [Connection timed out #110] Swiftmailer:无法与主机 smtp.gmail.com 建立连接 [连接超时 #110] - Swiftmailer: Connection could not be established with host smtp.gmail.com [Connection timed out #110] 如何解决:PHP中无法通过主机smtp.gmail.com建立连接[连接超时#110]错误 - How to resolve: Connection could not be established with host smtp.gmail.com [Connection timed out #110] error in PHP Lravel邮件未发送-无法与主机smtp.gmail.com建立连接[连接超时#110] - Lravel Mail not sending — Connection could not be established with host smtp.gmail.com [Connection timed out #110] Laravel 3-错误:与smtp.gmail.com的连接:465超时 - Laravel 3 - error: Connection to smtp.gmail.com:465 Timed Out 未捕获的异常“Swift_TransportException”带有消息“无法与主机 smtp.gmail.com 建立连接 [连接超时 #110]” - Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Connection timed out #110]' SMTP->错误:无法连接到服务器:连接超时(110) - SMTP -> ERROR: Failed to connect to server: Connection timed out (110) SMTP->错误:无法连接到服务器:连接超时(110)以下“发件人”地址失败:xxxxx@gmail.com错误 - SMTP -> ERROR: Failed to connect to server: Connection timed out (110) The following From address failed: xxxxx@gmail.com ERROR
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM