php - PHPMailer sends with TLS even when encryption is not enabled -


i trying sending email using phpmailer without tls, phpmailer still tries send email tls if not enable it:

include_once("phpmailer-master\phpmailerautoload.php");  $to = 'some@site.com'; $subject = 'topic'; $message = 'msg test';  $host = 'site.com.br'; $username = 'contact@site.com.br'; $password = 'pass'; $port = "587";  $mail = new phpmailer(); $body = $message; $mail->issmtp(); // telling class use smtp $mail->host = $host; // smtp server $mail->smtpdebug = 1; // enables smtp debug information (for testing) // 1 = errors , messages // 2 = messages $mail->smtpauth = true; // enable smtp authentication //$mail->smtpsecure = 'ssl'; //or tsl -> switched off $mail->port = $port; // set smtp port 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; } 

after send email, got message:

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 temporary reason 2016-09-01 21:08:55 smtp error: not connect 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 

the server doesn't support ssl or tls.

any idea?

this covered in phpmailer docs. phpmailer opportunistic tls - if server advertises can tls (which yours does), use automatically without asking. can disable this:

$mail->smtpsecure = false; $mail->smtpautotls = false; 

from error message, looks temporary problem on hosting provider. see more info if set $mail->smtpdebug = 2;.

i can see you've based code on obsolete example, make sure have the latest version of phpmailer , base code on examples supplied it.


Comments