CakePHP SwiftMailer SMTP TLS OpenSSL 错误 SSL3_GET_RECORD:wrong version number

6
我正在尝试使用CakePHP SwiftMailer组件发送电子邮件,我在这里找到了它:http://bakery.cakephp.org/articles/sky_l3ppard/2009/11/07/updated-swiftmailer-4-xx-component-with-attachments-and-plugins 我要发送的服务器使用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]

这是我的 PHP 信息中 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:版本号错误
这似乎是问题的根源。 有人知道这意味着什么吗?
3个回答

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

2

更新您的SwiftMailer库。我最近遇到了SwiftMailer 4.0.6的这个确切问题,并升级到了4.1.6 - 现在它像魔法一样运行:)


0

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

'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规则)。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接