good day I am using phpmailer to send an email the function send mail I call it through ajax and htaccess when the function sending the mail should return an answer echo json_encode (true); but I receive something like that
responseText:2019-07-30 21:49:58 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP y71sm15279487vsc.19 - gsmtp
↵2019-07-30 21:49:58 CLIENT -> SERVER: EHLO localhost
↵2019-07-30 21:49:58 SERVER -> CLIENT: 250-
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
function enviarCorreo($para, $contraseña)
{
require 'views/assets/lib/mailer/vendor/autoload.php';
try {
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'mail@gmail.com'; // SMTP username
$mail->Password = '******'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('mail@gmail.com', 'Biomatic');
$mail->addAddress($para); // Add a recipient
// // Attachments
// $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Cambio de clave';
$mail->Body = 'Buen dia se ha solicitado el cambio de contraseña su nueva contraseña es: <b>' . $contraseña . '</b>';
$mail->AltBody = 'Si no solicito con anterioridad el cambio de contraseña por fabor contacte al administrador de el sitio gracias.';
$mail->send();
echo json_encode(true);
}
I need the response text to be true so that the ajax can perform the required actions