[英]CakePHP SwiftMailer SMTP TLS OpenSSL Error SSL3_GET_RECORD:wrong version number
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 我正在尝试使用我在此处找到的CakePHP SwiftMailer组件发送电子邮件: http : //bakery.cakephp.org/articles/sky_l3ppard/2009/11/07/updated-swiftmailer-4-xx-component-with-attachments -and-插件
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: 我发送到的服务器使用带有TLS的SMTP通过端口25.这是我尝试发送邮件时出现的错误:
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: 这是我的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
And some more info from my phpinfo: 还有一些来自我的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
SSL操作失败,代码为1. OpenSSL错误消息:错误:1408F10B:SSL例程:SSL3_GET_RECORD:版本号错误
This seems to be the root of the problem. 这似乎是问题的根源。 Anyone know what exactly this means?
任何人都知道究竟是什么意思?
We have resolved this issue. 我们已经解决了这个问题。 The problem appeared to be with our SSL version and the connect method of SwiftMailer.
问题似乎与我们的SSL版本和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.
SwiftMailer组件尝试使用TLS进行连接,而首先需要以明文连接,然后启动TLS连接。 Hope this helps anyone else with this problem.
希望这可以帮助其他人解决这个问题。
Update your SwiftMailer libs. 更新您的SwiftMailer库。 I recently ran into this exact problem with SwiftMailer 4.0.6 and upgraded to 4.1.6 - now it works like a charm :)
我最近遇到了SwiftMailer 4.0.6这个确切的问题并升级到4.1.6 - 现在它就像一个魅力:)
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 ) 如果您使用的是EC2(AWS实例),那么您必须允许465端口(为SMTP创建自定义TCP规则 - 端口25或SMTPS - 端口465)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.