title: Emailing from Gmail using phpmailer. Login Error
body: <p>I cant seem to get my head around why i cant send emails using all sorts of mail classes in php. I know my password etc is correct.</p>
  
  <p>Any one have any ideas?</p>
  
  <p>I get the error:</p>
  
  <blockquote>
    <p>SMTP -> ERROR: Password not accepted from server: 534-5.7.14 Please
    log in via your web browser and 534-5.7.14 then try again. 534-5.7.14
    Learn more at 534 5.7.14
    <a href="https://support.google.com/mail/bin/answer.py?answer=78754" rel="nofollow">https://support.google.com/mail/bin/answer.py?answer=78754</a>
    dm6sm8657044wib.22 - gsmtp  SMTP Error: Could not authenticate. Mailer
    Error: SMTP Error: Could not authenticate.</p>
  </blockquote>
  
  <pre><code>function mail1($to,$body,$subject){
  
      include "/libs/mailer/classes/class.phpmailer.php"; // include the class name
      $mail = new PHPMailer(); // create a new object
      $mail-&gt;IsSMTP(); // enable SMTP
      $mail-&gt;SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
      $mail-&gt;SMTPAuth = true; // authentication enabled
      $mail-&gt;SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
      $mail-&gt;Host = "smtp.gmail.com";
      $mail-&gt;Port = 465; // or 587
      $mail-&gt;IsHTML(true);
      $mail-&gt;Username = "lewis.morris@gmail.com";
      $mail-&gt;Password = "xxxxxxxx";
      $mail-&gt;SetFrom("lewis.morris@gmail.com");
      $mail-&gt;Subject = $subject;
      $mail-&gt;Body = $body;
      $mail-&gt;AddAddress($to);
  
      if(!$mail-&gt;Send()){
          echo "Mailer Error: " . $mail-&gt;ErrorInfo;
      }
      else{
          echo "Message has been sent";
      }
  
  }
  </code></pre>