CakePHP SwiftMailer SMTP TLS OpenSSL 错误 SSL3_GET_RECORD:版本号错误

发布于 2024-12-02 23:15:17 字数 1981 浏览 1 评论 0原文

我正在尝试使用我在这里找到的 CakePHP SwiftMailer 组件发送电子邮件: http://bakery.cakephp.org/articles/sky_l3ppard/2009/11/07/updated-swiftmailer-4-xx-component-with-attachments-and-plugins

服务器我我发送到的是通过端口 25 使用带有 TLS 的 SMTP。 这是我尝试发送邮件时收到的错误:

Notice (8): Trying to get property of non-object [APP/views/helpers/hdl_session.php, line 14]

Warning (2): stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages:
error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number [CORE/vendors/classes/Swift/Transport/StreamBuffer.php, line 271]

Warning (2): stream_socket_client() [function.stream-socket-client]: Failed to enable crypto [CORE/vendors/classes/Swift/Transport/StreamBuffer.php, line 271]

Warning (2): stream_socket_client() [function.stream-socket-client]: unable to connect to tls://mail.aedisit.com:25 (Unknown error) [CORE/vendors/classes/Swift/Transport/StreamBuffer.php, line 271]

Warning (2): Illegal offset type in isset or empty [CORE/cake/libs/i18n.php, line 177]

Warning (2): Cannot modify header information - headers already sent by (output started at /srv/www/stage/hypercool/cake/libs/debugger.php:673) [CORE/cake/libs/controller/controller.php, line 742]

这是来自我的 phpinfo 的 OpenSSL 信息:

openssl
OpenSSL support     enabled
OpenSSL Library Version     OpenSSL 0.9.8o 01 Jun 2010
OpenSSL Header Version  OpenSSL 0.9.8o 01 Jun 2010 

还有一些更多信息来自我的 phpinfo:

PHP Version 5.3.5-1ubuntu7.2
Registered Stream Socket Transports     tcp, udp, unix, udg, ssl, sslv3, sslv2, tls 

非常感谢这里的任何帮助:-)

编辑:

SSL 操作失败,代码为 1。OpenSSL 错误消息: 错误:1408F10B:SSL 例程:SSL3_GET_RECORD:版本号错误

这似乎是问题的根源。有人知道这到底是什么意思吗?

I'm attempting to send an email using the CakePHP SwiftMailer component I found here:
http://bakery.cakephp.org/articles/sky_l3ppard/2009/11/07/updated-swiftmailer-4-xx-component-with-attachments-and-plugins

The server I'm sending to is using SMTP with TLS over port 25. Here's the error I get when I attempt to send a mail:

Notice (8): Trying to get property of non-object [APP/views/helpers/hdl_session.php, line 14]

Warning (2): stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages:
error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number [CORE/vendors/classes/Swift/Transport/StreamBuffer.php, line 271]

Warning (2): stream_socket_client() [function.stream-socket-client]: Failed to enable crypto [CORE/vendors/classes/Swift/Transport/StreamBuffer.php, line 271]

Warning (2): stream_socket_client() [function.stream-socket-client]: unable to connect to tls://mail.aedisit.com:25 (Unknown error) [CORE/vendors/classes/Swift/Transport/StreamBuffer.php, line 271]

Warning (2): Illegal offset type in isset or empty [CORE/cake/libs/i18n.php, line 177]

Warning (2): Cannot modify header information - headers already sent by (output started at /srv/www/stage/hypercool/cake/libs/debugger.php:673) [CORE/cake/libs/controller/controller.php, line 742]

Here's the OpenSSL info from my phpinfo:

openssl
OpenSSL support     enabled
OpenSSL Library Version     OpenSSL 0.9.8o 01 Jun 2010
OpenSSL Header Version  OpenSSL 0.9.8o 01 Jun 2010 

And some more info from my phpinfo:

PHP Version 5.3.5-1ubuntu7.2
Registered Stream Socket Transports     tcp, udp, unix, udg, ssl, sslv3, sslv2, tls 

Any help here is greatly appreciated :-)

EDIT:

SSL operation failed with code 1. OpenSSL Error messages:
error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number

This seems to be the root of the problem. Anyone know what exactly this means?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

好久不见√ 2024-12-09 23:15:17

我们已经解决了这个问题。问题似乎出在我们的 SSL 版本和 SwiftMailer 的连接方法上。 SwiftMailer 组件尝试使用 TLS 进行连接,但它首先需要以明文方式进行连接,然后启动 TLS 连接。希望这可以帮助其他人解决这个问题。

We have resolved this issue. The problem appeared to be with our SSL version and the connect method of SwiftMailer. The SwiftMailer component was attempting to connect using TLS, when instead it first needed to connect in plaintext, and then initiate the TLS connection. Hope this helps anyone else with this problem.

我爱人 2024-12-09 23:15:17

更新您的 SwiftMailer 库。我最近在 SwiftMailer 4.0.6 中遇到了这个问题,并升级到了 4.1.6 - 现在它就像一个魅力:)

Update your SwiftMailer libs. I recently ran into this exact problem with SwiftMailer 4.0.6 and upgraded to 4.1.6 - now it works like a charm :)

爱情眠于流年 2024-12-09 23:15:17

我已经解决了这个问题。
以下是您可以使用的配置:

'default' => [
    'className' => 'Smtp',
    'host' => 'ssl://smtp.gmail.com',
    'username' => 'GMAIL_EMAIL_ADDRESS',
    'password' => 'GMAIL_PASSWORD',
    'port' => 465, //here was the problem
    'timeout' => 50,
    'client' => null,
    'tls' => null,
    'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],

如果您使用 EC2(AWS 实例),则必须允许 465 端口(为 SMTP - 端口 25 或 SMTPS - 端口 465 创建自定义 TCP 规则)

I have resolved the issue.
Here is the configuration you can use:

'default' => [
    'className' => 'Smtp',
    'host' => 'ssl://smtp.gmail.com',
    'username' => 'GMAIL_EMAIL_ADDRESS',
    'password' => 'GMAIL_PASSWORD',
    'port' => 465, //here was the problem
    'timeout' => 50,
    'client' => null,
    'tls' => null,
    'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],

If you are using EC2 ( AWS Instance ) then you have to allow the 465 port ( create Custom TCP Rule for SMTP - port 25 or SMTPS - port 465 )

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