CakePHP SMTP 连接超时
我知道关于这个主题有很多问题,但仍然无法弄清楚出了什么问题。
这是我的代码:
$this->Email->to = '[email protected]';
$this->Email->subject = 'any subject';
$this->Email->replyTo = '[email protected]';
$this->Email->from = 'Somebody <[email protected]>';
$this->Email->additionalParams = '[email protected]';
$this->Email->template = 'my_template';
$this->Email->sendAs = 'text';
$this->Email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'host' => 'ssl://smtp.googlemail.com', // also tried smtp.gmail.com
'username'=>'username',
'password'=>'pass',
);
$this->Email->send();
现在这只会导致“连接超时:110”。我尝试了其他几种邮寄服务。总是出现连接错误。
非常感谢帮助。
I know there is a load of questions about this topic, but still can't figure out what is going wrong.
Here's my code:
$this->Email->to = '[email protected]';
$this->Email->subject = 'any subject';
$this->Email->replyTo = '[email protected]';
$this->Email->from = 'Somebody <[email protected]>';
$this->Email->additionalParams = '[email protected]';
$this->Email->template = 'my_template';
$this->Email->sendAs = 'text';
$this->Email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'host' => 'ssl://smtp.googlemail.com', // also tried smtp.gmail.com
'username'=>'username',
'password'=>'pass',
);
$this->Email->send();
Now this leads to nothing but "Connection timed out: 110". I tried several other mailing services. Always get the connection error.
Help very much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您缺少传送方式:
我认为
smtp.gmail.com
是您应该采用的方式 - 我不确定ssl
版本是否有效。1.2 手册在这个主题上做得更好(就像许多其他手册一样)。
尝试使用 http://book.cakephp.org/view/1635/Debugging- 调试代码电子邮件(或在适当的位置简单地
debug(someVar);exit;
)。You're missing the delivery method:
I think
smtp.gmail.com
is the way you should go - I'm not sure thessl
version will work.The 1.2 manual is much better on this topic (as it is with many others).
Try debugging the code using http://book.cakephp.org/view/1635/Debugging-Emails (or simply
debug(someVar);exit;
at the appropriate place).是的,我确实在代码示例中遗漏了这一点。
我已经调试过它,那就是我收到 110 错误的时候。
事实上,我现在设法正确设置它。似乎提供商阻止了端口或类似的东西,因为当我将其移动到另一台服务器时,一切正常。
尽管如此,还是感谢您的帮助!
Yeah, I really left that out in my code sample.
I already debugged it and that is when I received the 110 error.
In fact, I managed to set it up properly now. It seems like the provider blocked the ports or something like that, because when I moved it to another server everything worked out fine.
Nevertheless, thanks for your help!
检查服务器上端口 465 上的传出连接是否已打开。我也遇到了同样的问题,打开端口就解决了。
Check that outgoing connections on port 465 are open on your server. I had the same problem and opened the port solves it.