title: PHPMailer GMail Email sent but ..not received
body: <p><br/></p>
  
  <p>I have installed PHPMailer 6 and use it in an MVC application, as per the below,my email is apparently sent, but never received  :<br/></p>
  
  <pre><code>// Controller:
  
  $this-&gt;sendmailer = new PHPMailer(true);
          //$this-&gt;sendmailer-&gt;isSMTP();
          $this-&gt;sendmailer-&gt;SMTPDebug = 2;
          $this-&gt;sendmailer-&gt;SMTPAuth = true;
          $this-&gt;sendmailer-&gt;SMTPSecure = 'tls';
          $this-&gt;sendmailer-&gt;Host = 'smtp.gmail.com';
          $this-&gt;sendmailer-&gt;Port = 587;
          $this-&gt;sendmailer-&gt;Username = 'xxxxxx@gmail.com';
          $this-&gt;sendmailer-&gt;Password = 'xxxxxxx';
          $this-&gt;sendmailer-&gt;setFrom('xxxxxxx@gmail.com', 'Test PHPMailer / GMail');
  
  // In the inherited Controller...:
  
  
  $mail=$this-&gt;sendmailer;
  
  $subject="Mail Subject....";
  $content="HTML content";
  
      $mail-&gt;addAddress('jmbrosselin@jmbdev.com', 'JM Brosselin');
      $mail-&gt;Subject = $subject;
      $mail-&gt;isHTML();
      $mail-&gt;msgHTML($content);
  
      echo '&lt;pre&gt;';
          echo $message;
          echo '&lt;br/&gt;&lt;hr&gt;&lt;br/&gt;';
          print_r($mail);
  echo '&lt;/pre&gt;';
      die();
  </code></pre>
  
  <p>Note 1:  I have commented out the isSMTP() method which crashed the sendout, whatever the SMTP config i use (tls/587 or ssl /465...); Either than that, the email output seems correct ; <br/>
  Note 2: I have tested this config in a more simple non-MVC style and it works perfectly, eg, it is sent..AND received ! </p>
  
  <p>Oups..forgot to add the send method in the code transcript..obviously I had it inthe original script:<br/></p>
  
  <pre><code>if (!$mail-&gt;send()) {
              $message='&lt;br/&gt;Mailer Error: '. $mail-&gt;ErrorInfo;
          } else {
              $message='&lt;br/&gt;Message sent!';
          }
  </code></pre>
  
  <p>HI !<br/>
  and thanks to @Dhruvadeep.<br/>
  I'm using a French Google / Admin console so the menus are somewhat different, but I did enforce the 'less secure Apps Control' ; what I'm NOT doing is using the <br/>
  "<code>require 'PHPMailerAutoload.php';</code>" instruction; instead, I use Composer and the following:<br/></p>
  
  <pre><code>use PHPMailer\PHPMailer\PHPMailer;
  use PHPMailer\PHPMailer\SMTP;
  use PHPMailer\PHPMailer\Exception;
  </code></pre>
  
  <p><br/>
  in my 'controller'...<br/>
  I seem to have read that "<code>require 'PHPMailerAutoload.php';</code>" was outdated , I'm using v6.1.4 of PHPMailer…<br/>
  is this correct ?</p>
  
  <p>In fact, as configured, the Gmail requests works 'randomly' (…!) and takes a hell of a time to either get the mai out to the recipient email box, or ..not ! I have read that this could be due to GMail considering that I am sending spam ..But would this not be filtered / from the recipient mailbox, rather than from the issuing party (eg GMAIL …) ?
  <br/>
  Below my current setup:<br/></p>
  
  <pre><code>$this-&gt;sendmailer = new PHPMailer(true);
  //$this-&gt;sendmailer-&gt;isSMTP();
  $this-&gt;sendmailer-&gt;SMTPDebug = 2;
  
  $this-&gt;sendmailer-&gt;Host = 'smtp.gmail.com';
  //$this-&gt;sendmailer-&gt;Host =gethostbyname("smtp.gmail.com");
  $this-&gt;sendmailer-&gt;Port = 587;
  $this-&gt;sendmailer-&gt;SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
  $this-&gt;sendmailer-&gt;SMTPAuth = true;
  $this-&gt;sendmailer-&gt;Username = 'my_gmail_email_email@gmail.com';
  $this-&gt;sendmailer-&gt;Password = 'my_gmail_email_pwd';
  $this-&gt;sendmailer-&gt;setFrom('my_gmail_email_email', 'Test');
  </code></pre>