title: Send mail SMTP GMail and PHPMailer
body: <p>I have problem about sending mails with Google SMTP and latest version of PHPMailer. Here are a lot of questions, but the answers doesn't work for me.
  I am using free hosting with free subdomain <code>000webhost</code>.
  This is my standard PHP code for sending email from <code>PHPMailer</code> docs:</p>
  
  <pre><code>$mail-&gt;isSMTP();
  $mail-&gt;Host = 'smtp.gmail.com';
  $mail-&gt;SMTPAuth = true;
  $mail-&gt;Username = 'GMAIL EMAIL ACCOUNT';
  $mail-&gt;Password = 'MY PASSWORD FOR GMAIL EMAIL ACCOUNT';
  $mail-&gt;SMTPSecure = 'tlc';
  $mail-&gt;Port = 587;
  $mail-&gt;SMTPDebug  = 3;
  $mail-&gt;setFrom('EMAIL ADDRESS', 'EXAMPLE');
  $mail-&gt;addAddress('ADDRESS TO SEND', 'From contact form');
  
  $mail-&gt;addCC('cc@example.com');
  $mail-&gt;addBCC('bcc@example.com');
  
  $mail-&gt;Subject = 'Here is the subject';
  $mail-&gt;Body    = 'This is the HTML message body &lt;b&gt;in bold!&lt;/b&gt;';
  $mail-&gt;AltBody = 'This is the body in plain text for non-HTML mail clients';
  
  if(!$mail-&gt;send()) {
      echo 'Message could not be sent.';
      echo 'Mailer Error: ' . $mail-&gt;ErrorInfo;
  } else {
      echo 'Message has been sent';
  }
  </code></pre>
  
  <p>and I get this error:</p>
  
  <blockquote>
    <p>.... 2017-06-03 15:15:33  SERVER -> CLIENT: 535-5.7.8 Username and Password not accepted. Learn more at
                                          535 5.7.8  <a href="https://support.google.com/mail/?p=BadCredentials" rel="nofollow noreferrer">https://support.google.com/mail/?p=BadCredentials</a> 203sm11822739ywk.62 - gsmtp
    2017-06-03 15:15:33   SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. Learn more at
                                          535 5.7.8  <a href="https://support.google.com/mail/?p=BadCredentials" rel="nofollow noreferrer">https://support.google.com/mail/?p=BadCredentials</a> 203sm11822739ywk.62 - gsmtp
    2017-06-03 15:15:33 SMTP Error: Could not authenticate.
    .....</p>
  </blockquote>
  
  <p>I see same error if I use <code>ssl</code> with port <code>465</code>.</p>
  
  <p>In my <code>Gmail</code> email account 2-factory authentication is <code>OFF</code> and <code>Allow less secure apps</code> is <code>ON</code>.</p>
  
  <p>I really don't know what to do.</p>