CakePHP SMTP 连接超时

发布于 2024-10-20 06:49:58 字数 1505 浏览 2 评论 0原文

我知道关于这个主题有很多问题,但仍然无法弄清楚出了什么问题。

这是我的代码:

                $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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

短暂陪伴 2024-10-27 06:49:58

您缺少传送方式:

$this->Email->delivery = 'smtp';

我认为 smtp.gmail.com 是您应该采用的方式 - 我不确定 ssl 版本是否有效。

1.2 手册在这个主题上做得更好(就像许多其他手册一样)。

尝试使用 http://book.cakephp.org/view/1635/Debugging- 调试代码电子邮件(或在适当的位置简单地debug(someVar);exit;)。

You're missing the delivery method:

$this->Email->delivery = 'smtp';

I think smtp.gmail.com is the way you should go - I'm not sure the ssl 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).

樱桃奶球 2024-10-27 06:49:58

是的,我确实在代码示例中遗漏了这一点。

我已经调试过它,那就是我收到 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!

素罗衫 2024-10-27 06:49:58

检查服务器上端口 465 上的传出连接是否已打开。我也遇到了同样的问题,打开端口就解决了。

Check that outgoing connections on port 465 are open on your server. I had the same problem and opened the port solves it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文