title: PHPMailer SMTP Error: Could not authenticate using gmail as smtp server
body: <p>I am failing to send email in my application hosted on <a href="http://appfog.com" rel="nofollow">appfog</a>
  i am using the following code which works fine on localhost but fail on appfog.
  JPhpMailer extend class.PhpMailer.php</p>
  
  <pre><code>                    $mailer = new JPhpMailer(true);
                      $mailer-&gt;IsSMTP();
                      $mailer-&gt;Mailer = "smtp";
                      //$mailer-&gt;SMTPSecure == 'tls'; 
                      $mailer-&gt;Host = 'ssl://smtp.gmail.com';
                      $mailer-&gt;Port = '465';
                      $mailer-&gt;SMTPAuth = true;
                      //$mailer-&gt;SMTPSecure = true; 
                      $mailer-&gt;Username = 'me@gmail.com';
                      $mailer-&gt;Password = 'zzzzzzz';
                      $mailer-&gt;SetFrom($to['from'], $to['from_name']); 
                      $mailer-&gt;AddAddress($to['to'],$to['to_name'] ); 
                      $mailer-&gt;Subject = $to['subject'];
                      $mailer-&gt;Body = $to['body'];
                      $mailer-&gt;Send();
  </code></pre>
  
  <p>here is the line that in phpMailer that fails to execute`if ($tls) {
               if (!$this->smtp->StartTLS()) {
                 throw new phpmailerException($this->Lang('tls'));
               }</p>
  
  <pre><code>         //We must resend HELO after tls negotiation
          $this-&gt;smtp-&gt;Hello($hello);
        }
  
         $connection = true;
        if ($this-&gt;SMTPAuth) {
           if (!$this-&gt;smtp-&gt;Authenticate($this-&gt;Username, $this-&gt;Password)) {
           **strong text throw new phpmailerException($this-&gt;Lang('authenticate')); **            }
        }
       }
     $index++;
      if (!$connection) {
         throw new phpmailerException($this-&gt;Lang('connect_host'));
       }
  </code></pre>