Laravel使用gmail发送电子邮件

时间:2015-10-11 01:20:45

标签: php laravel-5 swiftmailer

我知道这个问题已被多次询问,但答案对我不起作用。我正在尝试使用Laravel 5通过gmail SMTP发送电子邮件。 这是我在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]

我尝试过使用smtp.gmail.com的IPv4,即74.125.200.108,但它给了我同样的错误。 我已经尝试将端口更改为587并加密到tls但是它给了我

Swift_TransportException in AuthHandler.php line 181: Failed to authenticate on SMTP server with username "myusername@gmail.com" using 2 possible authenticators

我还尝试使用新的Gmail帐户,该帐户没有两步验证,我启用了安全性较低的应用访问权限。仍然无效。

我几乎放弃了这一点。任何帮助或建议将不胜感激。

0 个答案:

没有答案
相关问题