I'm trying to use PHPMailer and it's not working. I even tried to contact Hostgator support, but the support passed me several doors, hosts to try and nothing worked. Finally, follow the code:
<?php
require 'class/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = 'mail.dominio.com.br';
$mail->SMTPAuth = true;
$mail->Username = 'user';
$mail->Password = 'pass';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->Subject = $Subject;
$mail->setFrom('mail', $Subject);
$mail->addAddress('mail', $Subject);
$mail->isHTML(true);
$mail->Body = $body;
?>
The error returned is the one with $ mail-> SMTPDebug = 3;:
2018-05-12 22:09:30 Connection: opening to mail.kadabra-box.com.br:587, timeout = 300, options = array () 2018-05-12 22:09:30 Connection: opened 2018-05-12 22:09:30 SERVER - > CLIENT: 220-srv180.prodns.com ESMTP Exim 4.89_1 # 1 Sat, 12 May 2018 19:09:30 -0300 220-We do not authorize the use of this system to transport unsolicited, 220 and / or bulk and -mail. 2018-05-12 22:09:30 CLIENT - > SERVER: EHLO kadabra-box.com 2018-05-12 22:09:30 SERVER - > CLIENT: 250-srv180.prodns.com.br Hello kadabra-box.com.br [108.179.192.227] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP 2018-05-12 22 : 09: 30 CLIENT - > SERVER: STARTTLS 2018-05-12 22:09:30 SERVER - > CLIENT: 220 TLS go ahead 2018-05-12 22:09:30 Connection failed. Error # 2: stream_socket_enable_crypto (): Peer certificate CN = *.prodns.com.br' did not match expected CN=
mail.kadabra-box.com.br '[/home/kadabrabox/public_html/wp-content/themes/kadabra/class/class.smtp.php line 370 ] 2018-05-12 22:09:30 SMTP Could not connect to SMTP host. 2018-05-12 22:09:30 CLIENT - > SERVER: QUIT 2018-05-12 22:09:30 SERVER - > CLIENT: 221 srv180.prodns.com closing connection 2018-05-12 22:09:30 Connection: closed 2018-05-12 22:09:30 SMTP connect () failed.