我正在尝试使用 Swift Mailer
在 Laravel
发送电子邮件,我一直在尝试过去3天但是 No Luck
.
我有Godaddy共享主机,我已经与_1392703讨论了,他们说从那边没有问题
我无法找到此代码中的错误 .
已经提到这篇文章,但没有得到任何解决方案 .
-
Laravel - Connection could not be established with host smtp.gmail.com [ #0]
-
Swift_TransportException Connection could not be established with host smtp.gmail.com
代码
$transport = \Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")
->setUsername('my@gmail.com')
->setPassword('*****');
$nam = 'abc';
$from = 'my@gmail.com';
$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(连接被拒绝)
3 回答
我使用了godaddy的旧服务器,我可以发送电子邮件 . 我不得不改变sendmail的路径 . 你可以在info.php上看到它 - >
并搜索:“sendmail_path”......
就我而言 sendmail_path 是"/usr/sbin/sendmail -t -i"
你应该把它放在config / mail.php上:
检查您的smtp连接电子邮件,尝试使用谷歌电子邮件进行测试
smtp.gmail.com port:587 secureconnection:true
在谷歌电子邮件安全连接中禁用
我有一个解决方案 . 使用此配置: