php does not send mail ()

0

I have a php code through the PHPmailer for which I want to send a password recovery mail, the mail says that it sends but in my inbox I do not see anything.

<?php 
include("connection.php");

date_default_timezone_set('Etc/UTC');
require('PHPMailer/PHPMailerAutoload.php');
$mail = new PHPMailer; 
$mail->isSMTP(); 
$mail->Host = 'smtp.gmail.com';       
$mail->SMTPAuth = true;      
$mail->Username = '[email protected]';   
$mail->Password = 'aqui tu password';                                                   
$mail->setFrom('[email protected]', 'gmail.com');
$mail->addAddress('[email protected]', 'Contact Message');     // Add a recipient
$mail->addAddress('[email protected]', 'Contact Message');     // Add a recipient
$mail->addReplyTo('[email protected]', 'gmail.com');
$mail->Subject = 'Contact fron website Hernandez Paiting';
$mail->IsHTML(true);
$mail->Subject = 'New Contact Message';

$mail->send();
$mail->SmtpClose();
if ( $mail->IsError() ) { 
    echo "Error: <" + $mail->ErrorInfo + " ><br /><br />";
}
else {
    if (headers_sent()){
         die('<script type="text/javascript">window.location.href="index.php";</script>');
    }else{
      header('Location: index.php');
      die();
    } 
}

if (isset($_POST["email"]) && !empty($_POST['email'])) {
    $email = trim($_POST['email']);
    $code = md5(uniqid(true));

    if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false ) {
        $checkmail = $connect->query("SELECT email FROM users WHERE email='$email'") or die(mysqli_error('Errorrrrrrr'));
        $count = mysqli_num_rows($checkmail);

        if ($count==1) {
            $to = $email;
            $subject = "Recuperar tu contraseña";
            $header = "Hernandez Paiting";
            $body = "Clickea en este link para recuperar tu contraseña: http://localhost/hernandez-painting/back-comentarios/chgpw.php?email=$email&code=$code";
            mail($to,$subject,$body);
         } 
         if($checkmail){
            echo "Se ha enviado un correo a tu email nuevo";
         }
         else{
            echo "Opps, correo no existe";
         }
    }
}

 ?>
    
asked by Tysaic 02.10.2017 в 21:47
source

0 answers