使用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)
答案 0 :(得分:6)
最简单的方法是在PEAR \ NET \ SMTP.php中函数auth的定义中将$ tls = true更改为$ tls = false
答案 1 :(得分:1)
使用当前版本的PEAR Mail包无法完成此操作 - 但is a requested feature。我上传了一个补丁,以便完成。希望很快就会发布新版本。
答案 2 :(得分:0)
转而使用PHPMailer,让它在5分钟内完成。