I try to test my code:
<?php
  use PHPMailer\PHPMailer\PHPMailer;
  use PHPMailer\PHPMailer\Exception;
  require_once __DIR__ . '/../PHPMailer/src/Exception.php';
  require_once __DIR__ . '/../PHPMailer/src/PHPMailer.php';
  require_once __DIR__ . '/../PHPMailer/src/SMTP.php';
        $mail = new PHPMailer(); // create a new object
        $mail->IsSMTP(); // enable SMTP
        $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
        $mail->SMTPAuth = true; // authentication enabled
        $mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for Gmail
        $mail->Host = "smtp.gmail.com";
        $mail->Port = 587;
        $mail->IsHTML(true);
        $mail->Username = "----------@gmail.com";
        $mail->Password = "************";
        $mail->SetFrom("--------@gmail.com");
        $mail->Subject = "Test";
        $mail->Body = "hello";
        $mail->AddAddress("-----------@gmail.com");
        if(!$mail->Send()) {
          header("Location: login.php"); // ---------------- EXECUTES ------------- \\
          exit();
       } else {
          header("Location: index.php");
          exit();
       }
?>
For some reason I can't figure out, it fails (because I'm getting re-directed to login.php).
I've tried to debug it with the latest ifs conditions..
