我正尝试使用Swift Mailer
发送电子邮件Laravel
,我一直试图从最近3天,但No Luck
。
Laravel:Swift_TransportException无法与主机建立连接smtp.gmail.com
我GoDaddy的共享主机,我已经与Customer Support
讨论,他们表示没有从那里边
问题,我无法找到什么是错的这个代码。
已经推荐这篇文章,但没有得到任何解决方案。
- Laravel - Connection could not be established with host smtp.gmail.com [ #0]
- Swift_TransportException Connection could not be established with host smtp.gmail.com
- Connection could not be established with host smtp.gmail.com [Connection timed out #110] in laravel 5.2
- How to resolve the error: Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)
代码
$transport = \Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")
->setUsername('[email protected]')
->setPassword('*****');
$nam = 'abc';
$from = '[email protected]';
$message = \Swift_Message::newInstance($subject)
->setFrom(array($from => $name))
->setTo(array($to))
->setBody($body);
$message->setContentType("text/html");
$mailer = \Swift_Mailer::newInstance($transport);
$result = $mailer->send($message);
return $result;
Please ignore Variable declaration, like $subject and ect....
Port Tried。
1. 465
2. 587
3. 80
4. 25
5. 110 (Gmail Commercial Email)
它表示错误
消息:的fsockopen():无法连接到SSL://smtp.gmail.com:465 (连接被拒绝)
你已经可以在你的Gmail帐户不安全的应用程序?这通常阻碍了连接。 – FMashiro
是的,它允许 –
'Godaddy Shared hosting'这是你的问题 – Ian