Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel使用gmail发送电子邮件_Php_Laravel 5_Swiftmailer - Fatal编程技术网

Php Laravel使用gmail发送电子邮件

Php Laravel使用gmail发送电子邮件,php,laravel-5,swiftmailer,Php,Laravel 5,Swiftmailer,我知道这个问题已经被问过很多次了,但答案对我来说并不适用。我正在尝试通过gmail SMTP使用Laravel 5发送电子邮件。 这是我在mail.php中的配置 'driver' => 'smtp', 'host' => 'smtp.gmail.com', 'port' => 465, 'encryption' => 'ssl', 'username' => 'myusername@gmail.com', 'password' => 'mypassword'

我知道这个问题已经被问过很多次了,但答案对我来说并不适用。我正在尝试通过gmail SMTP使用Laravel 5发送电子邮件。 这是我在mail.php中的配置

'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'encryption' => 'ssl',
'username' => 'myusername@gmail.com',
'password' => 'mypassword', // uses specific-application password
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
这种配置在我的本地机器上运行良好,但当我将其上传到真正的服务器时,它会给我

Swift_TransportException in StreamBuffer.php line 265: Connection could not be established with host smtp.gmail.com [Connection timed out #110]
Swift_TransportException in AuthHandler.php line 181: Failed to authenticate on SMTP server with username "myusername@gmail.com" using 2 possible authenticators
我尝试使用smtp.gmail.com的IPv4,它是74.125.200.108,但它给了我相同的错误。 我曾尝试将端口更改为
587
,将加密更改为
tls
,但后来它给了我

Swift_TransportException in StreamBuffer.php line 265: Connection could not be established with host smtp.gmail.com [Connection timed out #110]
Swift_TransportException in AuthHandler.php line 181: Failed to authenticate on SMTP server with username "myusername@gmail.com" using 2 possible authenticators
我还尝试使用一个新的gmail帐户,该帐户没有两步验证,我可以访问不太安全的应用程序。还是不行

我几乎要放弃了。如有任何帮助或建议,将不胜感激