2016-09-01 16 views
5

我試圖發送使用PHPMailer的電子郵件不使用TLS,但PHPMailer的仍然嘗試使用TLS發送郵件,即使我不啓用它:PHPMailer的使用TLS發送,即使不啓用加密

include_once("PHPMailer-master\PHPMailerAutoload.php"); 

$To = '[email protected]'; 
$Subject = 'Topic'; 
$Message = 'msg test'; 

$Host = 'site.com.br'; 
$Username = '[email protected]'; 
$Password = 'pass'; 
$Port = "587"; 

$mail = new PHPMailer(); 
$body = $Message; 
$mail->IsSMTP(); // telling the class to use SMTP 
$mail->Host = $Host; // SMTP server 
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing) 
// 1 = errors and messages 
// 2 = messages only 
$mail->SMTPAuth = true; // enable SMTP authentication 
//$mail->SMTPSecure = 'ssl'; //or tsl -> switched off 
$mail->Port = $Port; // set the SMTP port for the service server 
$mail->Username = $Username; // account username 
$mail->Password = $Password; // account password 

$mail->SetFrom($Username); 
$mail->Subject = $Subject; 
$mail->MsgHTML($Message); 
$mail->AddAddress($To); 

if(!$mail->Send()) { 
    $mensagemRetorno = 'Error: '. print($mail->ErrorInfo); 
    echo $mensagemRetorno; 
} else { 
    $mensagemRetorno = 'E-mail sent!'; 
    echo $mensagemRetorno; 
} 

發送電子郵件後,我收到此消息:

2016-09-01 21:08:55 CLIENT -> SERVER: EHLO www.johnmendes.com.br 
2016-09-01 21:08:55 CLIENT -> SERVER: STARTTLS 
2016-09-01 21:08:55 SMTP ERROR: STARTTLS command failed: 454 TLS not available due to temporary reason 
2016-09-01 21:08:55 SMTP Error: Could not connect to SMTP host. 
2016-09-01 21:08:55 CLIENT -> SERVER: QUIT 
2016-09-01 21:08:55 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 
Erro ao enviar e-mail: 1 

服務器不支持ssl或tls。

有什麼想法?

回答

12

這包含在PHPMailer文檔中。 PHPMailer做機會主義TLS - 如果服務器宣傳它可以做TLS(你的做法),它會自動使用它,而不用問你。您可以禁用此:

$mail->SMTPSecure = false; 
$mail->SMTPAutoTLS = false; 

從錯誤消息,它看起來像這是您的託管服務提供商的臨時問題。如果您設置$mail->SMTPDebug = 2;,您會看到更多信息。

我可以看到你已經將你的代碼基於一個過時的例子,所以確保你有the latest version of PHPMailer並且將你的代碼基於它提供的例子。