php CodeIgniter:来自 PHPMailer 代码的 SSL/TLS SMTP 身份验证电子邮件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7713701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CodeIgniter: SSL/TLS SMTP Auth Email from PHPMailer Code
提问by jjwdesign
I'm trying to use the CodeIgniter Email Class to write a secure SMTP email; either SSL or TLS (preferred). In the past, I've successfully used PHPMailer with Secure Auth and TLS. I believe it was a secure connection. TLS shows up in the email header.
我正在尝试使用 CodeIgniter 电子邮件类编写安全的 SMTP 电子邮件;SSL 或 TLS(首选)。过去,我成功地将 PHPMailer 与 Secure Auth 和 TLS 结合使用。我相信这是一个安全的连接。TLS 显示在电子邮件标头中。
Does CodeIngiters' Email Class support secure SMTP authentication with TLS?
CodeIngiters 的电子邮件类是否支持使用 TLS 的安全 SMTP 身份验证?
Note, this is not a Gmail question. I'm trying to use it with an MS Exchange Server. I've confirmed the PHPMailer code below functions correctly.
请注意,这不是 Gmail 问题。我正在尝试将它与 MS Exchange Server 一起使用。我已经确认下面的 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 = '[email protected]';
$mail->Password = 'password';
$mail->From = '[email protected]';
$mail->FromName = 'Alerts';
$mail->Subject = 'Test from test email file.';
$mail->IsHTML(true);
$mail->MsgHTML('This is just a test.');
// To
$mail->AddAddress('[email protected]', 'Research');
$result = $mail->Send();
With CodeIgniter I've already extended the Email Class (MY_Email.php). The class is a bit big to post here. But, here's the error I keep getting.
使用 CodeIgniter,我已经扩展了电子邮件类 (MY_Email.php)。类有点大,在这里发帖。但是,这是我不断收到的错误。
Settings:
设置:
array(7) {
["smtp_host"]=> string(26) "tls://www.domain.com"
["smtp_port"]=> string(2) "25"
["smtp_user"]=> string(17) "[email protected]"
["smtp_pass"]=> string(9) "password"
["smtp_to_email"]=> string(26) "[email protected]"
["smtp_from_email"]=> string(26) "[email protected]"
["smtp_from_name"]=> string(24) "Test from Application"
}
Error Message:
错误信息:
fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:1408F10B:SSL routines:func(143):reason(267)
fsockopen():SSL 操作失败,代码为 1。 OpenSSL 错误消息:错误:1408F10B:SSL 例程:func(143):reason(267)
Any idea what reason 267 is?
知道 267 是什么原因吗?
采纳答案by jjwdesign
Found a solution on the CI forums.
在 CI 论坛上找到了解决方案。
Exchange Email Class Patch http://codeigniter.com/forums/viewthread/158882/
Exchange 电子邮件类补丁 http://codeigniter.com/forums/viewthread/158882/
It is initiating TLS afterSMTP server has been connected.
它在SMTP 服务器连接后启动 TLS 。
Worked for me. Jeff
为我工作。杰夫
回答by hakre
How to diagnose OpenSSL errors:
如何诊断 OpenSSL 错误:
Look at the error message:
查看错误信息:
error:1408F10B:SSL routines:func(143):reason(267)
Take the reason code (267) and determine the error:
取原因码 (267) 并确定错误:
grep 267 /usr/include/openssl/ssl.h
/usr/include/openssl/ssl.h:#define SSL_R_WRONG_VERSION_NUMBER 267
Now google for SSL_R_WRONG_VERSION_NUMBER
现在谷歌搜索 SSL_R_WRONG_VERSION_NUMBER
Read the first hit: http://www.mail-archive.com/[email protected]/msg02770.html
阅读第一篇:http: //www.mail-archive.com/[email protected]/msg02770.html
"
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.
"
Conclusion: the smtp-server uses SSLv3_server_method and therefore needs to be fixed to use SSLv23 instead.
结论:smtp-server 使用 SSLv3_server_method,因此需要修复以使用 SSLv23。