CodeIgniter:来自phpMail代码的SSL/TLS SMTP身份验证电子邮件

CodeIgniter:来自phpMail代码的SSL/TLS SMTP身份验证电子邮件,php,codeigniter,email,smtp,Php,Codeigniter,Email,Smtp,我正在尝试使用CodeIgniter电子邮件类来编写安全的SMTP电子邮件;SSL或TLS(首选)。在过去,我已经成功地将PHPMailer与secureauth和TLS一起使用。我相信这是一个安全的连接。TLS显示在电子邮件标题中 Codeingiter的电子邮件类是否支持使用TLS的安全SMTP身份验证 注意,这不是Gmail的问题。我正在尝试将其用于MS Exchange服务器。我已经确认下面的PHPMailer代码功能正确 include_once('includes/class.php

我正在尝试使用CodeIgniter电子邮件类来编写安全的SMTP电子邮件;SSL或TLS(首选)。在过去,我已经成功地将PHPMailer与secureauth和TLS一起使用。我相信这是一个安全的连接。TLS显示在电子邮件标题中

Codeingiter的电子邮件类是否支持使用TLS的安全SMTP身份验证

注意,这不是Gmail的问题。我正在尝试将其用于MS Exchange服务器。我已经确认下面的PHPMailer代码功能正确

include_once('includes/class.phpmailer.php');
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->Host = 'www.domain.com';

$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Port     = '25';
$mail->Timeout  = '60';

$mail->Username = 'user@domain.com';
$mail->Password = 'password';

$mail->From     = 'alerts@domain.com';
$mail->FromName = 'Alerts';

$mail->Subject  = 'Test from test email file.';
$mail->IsHTML(true);
$mail->MsgHTML('This is just a test.');

// To
$mail->AddAddress('alerts@domain.com', 'Research');
$result = $mail->Send();
使用CodeIgniter,我已经扩展了Email类(MY_Email.php)。这个班级有点大,可以在这里发布。但是,这是我一直得到的错误

设置:

array(7) { 
["smtp_host"]=> string(26) "tls://www.domain.com" 
["smtp_port"]=> string(2) "25" 
["smtp_user"]=> string(17) "alerts@domain.com" 
["smtp_pass"]=> string(9) "password" 
["smtp_to_email"]=> string(26) "user@domain.com" 
["smtp_from_email"]=> string(26) "user@domain.com" 
["smtp_from_name"]=> string(24) "Test from Application" 
}
错误消息:

fsockopen():SSL操作失败,代码为1。OpenSSL错误消息:错误:1408F10B:SSL例程:func(143):原因(267)


知道267是什么原因吗?

如何诊断OpenSSL错误:

查看错误消息:

error:1408F10B:SSL routines:func(143):reason(267)
获取原因代码(267)并确定错误:

grep 267 /usr/include/openssl/ssl.h
/usr/include/openssl/ssl.h:#define SSL_R_WRONG_VERSION_NUMBER                    267
现在谷歌搜索
SSL\u R\u错误版本号

阅读第一首热门歌曲:


结论:smtp服务器使用SSLv3_server_方法,因此需要修复以使用SSLv23。

在CI论坛上找到了解决方案

Exchange电子邮件类修补程序

它在连接SMTP服务器后启动TLS


为我工作。Jeff

您可以通过谷歌搜索错误代码来了解更多信息,也可以在codeigniter中使用PHPMailer。您可以使用CI的PHP库旁边的其他PHP库,如果您已经有了可以工作的代码,这可能是一个好主意。如果您的PHP库在PHPMailer中工作,那么我将把它作为库包含在CI中。我个人过去在CI的电子邮件类中遇到过问题,并且做过同样的事情。根据phpinfo()-注册的流套接字传输:tcp、udp、unix、udg、ssl、sslv3、sslv2、tls。有没有办法将PHP配置为使用SSLV3进行TLS连接?我认为您没有正确理解这一点。但是,为什么不直接使用PHPMailer类就可以了?升级到CodeIgniter V3。
"
    Many of SSL clients sends the first CLIENT HELLO with
    ssl2 format (0x80.....) because they don't know what
    version the server supports.
    In this first message, the client sends the version
    he wants to use (3 for SSL3), then the other exchanged
    messages are in the appropriate format SSL3 for V3,
    SSL2 for V2 etc....

    So in your server method configuration you must put:
      SSL_CTX *ctx = SSL_CTX_new (SSLv23_server_method())
    to correctely analyse the first client_hello message
    instead of 
      SSL_CTX *ctx = SSL_CTX_new (SSLv3_server_method())
    which i suppose you did.
"