title: Use php mailer to send via Gmail - SMTP error
body: <p>I just registered a domain via gsuite/gmail to use this as a new mailserver domain for my php mailer.</p>
  <p>Now I read through most related topics and adapted the hints, but I still receive the error message:</p>
  <pre><code>Message could not be sent.
  
  Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
  </code></pre>
  <p>Here is my code:</p>
  <pre><code>$mail-&gt;Subject = &quot;Tutor found for help&quot;;    
  
  //From email address and name
  $mail-&gt;setFrom('frank@xxx.net', 'xxx.net');
  
  $mail-&gt;addAddress(&quot;$clientmail&quot;, &quot;$clientname&quot;);
  //$mail-&gt;addAddress(&quot;nachhilfeanfrage@xxx.net&quot;, &quot;xxx.net&quot;);
  
  $mail-&gt;addReplyTo('frank@xxx.net', 'xxx.net');
  
  $mail-&gt;IsSMTP(); // enable SMTP
  $mail-&gt;SMTPDebug = 2;  // 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;SMTPAutoTLS = false;
  $mail-&gt;Host = 'smtp.gmail.com';
  $mail-&gt;Port = 587;    // Port for TLS Gmail
  $mail-&gt;Username = 'xx';   // SMTP username
  $mail-&gt;Password = 'xx';     
  
  $mail-&gt;isHTML(true);
  $mail-&gt;CharSet = 'UTF-8';
  </code></pre>