如何显式禁用PEAR邮件工厂的TLS?
问题描述:
使用PHP,我试图通过AuthSMTP(托管的SMTP服务)路由电子邮件。问题是PEAR邮件工厂自动尝试与服务器协商TLS连接。 AuthSMTP不会简单地忽略该尝试,而会引发错误。我需要一种方法来明确告诉Mailer类不要尝试使用TLS。有什么建议么?如何显式禁用PEAR邮件工厂的TLS?
$from = "Example <[email protected]>";
$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)
答
切换到使用的PHPMailer来代替,把它在5分钟内工作。
答
最简单的办法是改变$ TLS = true以$ TLS =在PEAR \ NET \ SMTP.php的功能权威性的定义
+0
这对我来说很有效,我和OP有同样的问题。这摆脱了AuthSMTP的错误消息,但仍然允许我通过GMail等进行SSL发送。谢谢@尼尔! – Michael 2013-11-20 00:27:24
酷假。我很欣赏对社区反馈的回应和回应。我会密切关注下一个项目的更新版本。 – jamieb 2010-10-19 22:55:49