title: Failed to send email using PHPMailer
body: <p>I try to test my code:</p>
  
  <pre><code>&lt;?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-&gt;IsSMTP(); // enable SMTP
          $mail-&gt;SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
          $mail-&gt;SMTPAuth = true; // authentication enabled
          $mail-&gt;SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for Gmail
          $mail-&gt;Host = "smtp.gmail.com";
          $mail-&gt;Port = 587;
          $mail-&gt;IsHTML(true);
          $mail-&gt;Username = "----------@gmail.com";
          $mail-&gt;Password = "************";
          $mail-&gt;SetFrom("--------@gmail.com");
          $mail-&gt;Subject = "Test";
          $mail-&gt;Body = "hello";
          $mail-&gt;AddAddress("-----------@gmail.com");
          if(!$mail-&gt;Send()) {
            header("Location: login.php"); // ---------------- EXECUTES ------------- \\
            exit();
         } else {
            header("Location: index.php");
            exit();
         }
  ?&gt;
  </code></pre>
  
  <p>For some reason I can't figure out, it fails (because I'm getting re-directed to <code>login.php</code>).
  I've tried to debug it with the latest <code>if</code>s conditions..</p>