title: "Password not accepted from server: 535 Incorrect authentication data" when sending with GMail and phpMailer
body: <p>I have the same php script running on localhost - my PC  with XAMPP and on a hosted server. It works from my PC, but not from the hosted server. </p>
  
  <p>When I send it from the hosted server, I get the following output:</p>
  
  <pre><code>SMTP -&gt; ERROR: Password not accepted from server: 535 Incorrect authentication data  
  SMTP -&gt; ERROR: RCPT not accepted from server: 550-Please turn on SMTP Authentication in your mail client, or login to the 550-IMAP/POP3 server before sending your message. dev.camppage.com 550-(patchvalues.com) [205.234.141.238]:50958 is not permitted to relay through 550 this server without authentication.  
  SMTP Error: The following recipients failed: jdorner4@gmail.com FAILED
  </code></pre>
  
  <p>I suspect there is a configuration setting that needs to be changed on the server, but I don't know which one. Any advice would be greatly appreciated!</p>
  
  <p>Here is the code: </p>
  
  <pre><code>function send_gmail ($recipients, $subject, $message, $attachment_filenames = array()) 
  {
    global $email_address, $email_password, $email_name;
    require_once ($_SERVER['DOCUMENT_ROOT']. '/php/PHPMailer/class.phpmailer.php');   
  
    $body  = $message;
    $body  = str_replace("\\", '', $body);
    $mail = new PHPMailer();
    $mail-&gt;CharSet = "UTF-8";
    $mail-&gt;IsSMTP();
    $mail-&gt;Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
    $mail-&gt;SMTPDebug  = 1;                     // enables SMTP debug information (for testing) 0 - none; 1 - errors &amp; messages; 2 - messages only
    $mail-&gt;SMTPAuth   = true;                  // enable SMTP authentication
    $mail-&gt;SMTPSecure = "ssl";                 // sets the prefix to the servier
    $mail-&gt;Port       = 465;                   // set the SMTP port
    $mail-&gt;Username   = $email_address;  // GMAIL username
    $mail-&gt;Password   = $email_password; // GMAIL password
    $mail-&gt;SetFrom($email_address);
    $mail-&gt;FromName   = $email_name;
    $mail-&gt;AddReplyTo($email_address,$email_name);
    $mail-&gt;Subject    = $subject;
    $mail-&gt;MsgHTML($body);
    $mail-&gt;IsHTML(true); // send as HTML
  
    if (isset ($recipients[0]))
    {
      foreach ($recipients AS $to)
      {
          $to_pieces = explode (",", $to, 2);
          $to_email = trim ($to_pieces[0]);
          if (isset ($to_pieces[1]))
              $to_name = trim ($to_pieces[1]);
          else
              $to_name = " ";
          $mail-&gt;AddAddress($to_email, $to_name);
      }
      $mail-&gt;IsHTML(true); // send as HTML
  
      if ($mail-&gt;Send()){
          return TRUE;
      } else {
          return FALSE;
      }
  } 
  else 
  {
      return FALSE;
  }
  }
  </code></pre>
  
  <p>TIA</p>