title: Google SMTP Error: Could not authenticate
body: <p>The following code does not work once i put it on the server, I have similar code working on my local environment and it works perfectly, any ideas?</p>
  
  <p>edit: i did set my gmail setting to "less secure"</p>
  
  <pre><code>&lt;?php
  $setid = $_POST['setid'];
  $promo = $_POST['promo'];
  
  
  echo "Good Sir, your set ID is ".$setid.", and you are eligible for the following deal:";
  echo "&lt;br&gt;&lt;br&gt;";
  echo $promo;
  
  $message=  "Good Sir, your set ID is ".$setid.", and you are eligible for the following deal:"."&lt;br&gt;&lt;br&gt;".$promo;
  
      require "phpmailer/class.phpmailer.php";
  
      // Instantiate Class  
      $mail = new PHPMailer();
  
      // Set up SMTP  
      $mail-&gt;IsSMTP();               
      $mail-&gt;SMTPAuth = true;         
      $mail-&gt;SMTPSecure = "ssl"; 
      $mail-&gt;Host = "smtp.gmail.com"; 
      $mail-&gt;Port = 465; 
      $mail-&gt;Encoding = '7bit';
  
      // Authentication  
      $mail-&gt;Username   = "xxx@example.com";
      $mail-&gt;Password   = "mypass";
  
      // Compose
      $mail-&gt;SetFrom("jghh@ghh.ca");
      $mail-&gt;AddReplyTo("ghh@ghh.ca");
      $mail-&gt;Subject = "TryIt";
      $mail-&gt;MsgHTML($message);
  
      // Send To  
      $mail-&gt;AddAddress("receiver@hotmail.com", "Recipient Name");
      $result = $mail-&gt;Send();
      $message = $result ? 'Successfully Sent!' : 'Sending Failed!';     
  
      unset($mail);
  
  
  
  ?&gt;
  </code></pre>
  
  <p>This is what I get in Network -> Preview:</p>
  
  <p>Good Sir, your set ID is 100065, and you are eligible for the following deal:</p>
  
  <p>Current Promotion: Enjoy 15% discount on your next visit!SMTP Error: Could not authenticate. </p>