[英]Connection could not be established with host smtp.gmail.com [Connection timed out #110] in laravel 5.2
[英]Using gmail smtp via Laravel: [Connection timed out #110]
在進行投票或復制之前,請閱讀說明 。
我知道這個問題被多次詢問並且有不同的解決方案,我已經嘗試了所有但沒有人工作過。 這是我的設置。
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=abc@mydomain.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=ssl
目前,應用程序正在Centos 7
OS上運行。
我總是得到
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
我嘗試了所有解決方案,通過替換: 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
。 當我執行這兩個步驟時,它找不到服務器錯誤。
如果我將郵件驅動程序從smtp to sendmail or mail
更改smtp to sendmail or mail
,則不會拋出任何錯誤,但不會發送電子郵件。
如果我使用smtp.gmail.com的ip地址,我得到了相同的結果。 如果我將端口從465 to 587
更改465 to 587
並從ssl to tls
加密ssl to tls
,則沒有任何反應。
我還在etc/gai.conf
創建了一個文件並輸出precedence ::ffff:0:0/96 100
。 它工作了一次。 但是兩個小時后,它停止工作並開始拋出相同的錯誤。
我也試過使用我的gmail id,但都是徒勞的。
我無法測試的唯一解決方案是驗證httpd_can_sendmail
因為每當我運行命令getsebool httpd_can_sendmail
我得到getsebool: SELinux is disabled
。 這是問題還是有其他方法來解決它?
這是我的工作郵件配置文件:
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',
];
但從你的問題我可以看到你已經嘗試了所有這些,所以我可以假設這是一個基於錯誤'連接超時'的網絡問題,我的意思是有什么東西阻止你的連接,它可能是你的防火牆,如果你有。
所以首先你應該檢查端口587是否打開,或者你可以檢查其他應用程序是否可以與smtp.gmail.com連接(不知道如何在centOs中進行)。
最后這可能不是問題,但您必須在Google帳戶中啟用“允許安全性較低的應用”才能進行測試。 (這不是永久解決方案,但是對於測試,如果它有效,那么你應該在谷歌帳戶中啟用兩步驗證然后創建新的應用程序,你可以創建新的特殊密碼,你可以使用它作為smtp服務器的密碼)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.