2016-09-01 11 views
5

を有効にしていない場合でも、私はTLSなしphpmailerのを使用してメール送信をしようとしていますが、phpmailerのは、まだ私はそれを有効にしない場合でも、TLSでメールを送信しようとTLSで送信:送信メールの後phpmailerのは、暗号化が

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があることを確認して、付属のサンプルに基づいてコードを作成してください。