【发布时间】:2011-12-04 13:11:23
【问题描述】:
我正在尝试使用 CodeIgniter 电子邮件类来编写安全的 SMTP 电子邮件; SSL 或 TLS(首选)。过去,我已经成功地将 PHPMailer 与 Secure Auth 和 TLS 一起使用。我相信这是一个安全的连接。 TLS 显示在电子邮件标题中。
CodeIngiters 的电子邮件类是否支持使用 TLS 的安全 SMTP 身份验证?
请注意,这不是 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 = '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,我已经扩展了电子邮件类 (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 错误消息:error:1408F10B:SSLroutines:func(143):reason(267)
知道 267 是什么原因吗?
【问题讨论】:
-
您可以通过谷歌搜索错误代码以了解更多信息,或者仅在 codeigniter 中使用 PHPMailer。您可以使用 CI 旁边的其他 PHP 库,如果您已经拥有 正在运行的代码,这可能是个好主意。
-
如果你让它在 PHPMailer 中工作,那么我会把它作为一个库包含在 CI 中。我个人过去曾在 CI 的电子邮件课程上遇到过问题,并且也做过同样的事情。
标签: php codeigniter email smtp