[英]How to explicitly disable TLS with PEAR Mail factory?
我正在尝试使用PHP通过AuthSMTP(托管的SMTP服务)路由电子邮件。 问题在于,PEAR邮件工厂会自动尝试与服务器协商TLS连接。 AuthSMTP不仅会忽略尝试,还会引发错误。 我需要一种方法明确告诉Mailer类不要尝试使用TLS。 有什么建议么?
$from = "Example <noreply@example.com>";
$to = $email;
$subject = "This is an email";
$body_text = "plain text here";
$body_html = "<h1>HTML here!</h1>";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$mime = new Mail_mime('rn');
$mime->setTXTBody($body_text);
$mime->setHTMLBody($body_html);
$body = $mime->get();
$hdrs = $mime->headers($headers);
$host = "mail.authsmtp.com";
$port = 26;
$username = "my_username";
$password = "whatever_password";
$mailer = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'port' => $port,
'username' => $username,
'password' => $password));
if (PEAR::isError($res)) {
throw new Exception($res->getMessage());
} else {
return true;
}
AuthSMTP给我以下错误:
SMTP: Invalid response code received from server (code: 428, response: 4.0.0 Your account is using SSL - either disable it in your email client or enable it at http://control.authsmtp.com)
最简单的方法是在PEAR \\ NET \\ SMTP.php中将函数auth的定义中的$ tls = true更改为$ tls = false。
当前版本的PEAR Mail软件包不能做到这-但是这是一个必需的功能 。 我已经上传了补丁程序,以便可以完成此操作。 希望很快会发布一个新版本。
改用PHPMailer,并且在5分钟内即可正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.