title: “SMTP Error: Could not authenticate” in PHPMailer for outlook
body: <p>I'm using PHPMailer in a Simple Script For Send Email's Through office360, and I'm getting an "Unknown Error"</p>
  
  <p><strong>SMTP -> ERROR: Password not accepted from server: 
  SMTP -> ERROR: RSET failed: 235 2.7.0 Authentication successful target host PS1PR06MB1083.apcprd06.prod.outlook.com 
  SMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate.
  SMTP server error: 2.7.0 Authentication successful target host PS1PR06MB1083.apcprd06.prod.outlook.com</strong></p>
  
  <pre><code>&lt;?php
      //error_reporting(E_ALL);
      error_reporting(E_STRICT);
  
      date_default_timezone_set('America/Toronto');
  
      require_once('class.phpmailer.php');
      include("class.smtp.php"); // optional, gets called from within 
      class.phpmailer.php if not already loaded
  
      $mail             = new PHPMailer();
      $mail-&gt;CharSet = 'UTF-8';
      if(isset($_POST['upload']))
        {
      $name = $_REQUEST['name'] ;
      $email = $_REQUEST['email'] ;
      $message = $_REQUEST['comments'] ;
       //$body             = file_get_contents('contents.html');
       //$body             = eregi_replace("[\]",'',$body);
  
      $mail-&gt;IsSMTP(); // telling the class to use SMTP
      $mail-&gt;Host       = "smtp.office365.com"; // SMTP server
      $mail-&gt;SMTPDebug  = 1;                     // enables SMTP debug information 
      (for testing)
                                             // 1 = errors and messages
      $mail-&gt;SMTPSecure = "tls";                                    // 2 = 
       messages only
      $mail-&gt;SMTPAuth   = true;                  // enable SMTP authentication
      $mail-&gt;Host       = "smtp.office365.com"; // sets the SMTP server
      $mail-&gt;Port       = 587;                    // set the SMTP port for the 
      GMAIL server
      $mail-&gt;Username   = "no-reply@outlook.ac.in"; // SMTP account username
      $mail-&gt;Password   = "outlookpassword";        // SMTP accountlt password
  
      $mail-&gt;SetFrom('no-reply@outlook.ac.in', 'First Last');
      $mail-&gt;AddReplyTo("aaa@outlook.ac.in","First Last");
  
      $mail-&gt;Subject    = "Website Feedback";
  
      $mail-&gt;AltBody    = $comments; // optional, comment out and test
      $body = "Dear Sir  !
  
      Name of the Candidate : $name &lt;br/&gt;
      Email id : $email &lt;br/&gt;
      Comments : $message"; 
      $mail-&gt;MsgHTML($body);
  
      $address = "aaaa@outlook.ac.in";
      $mail-&gt;AddAddress($address, "aaa");
      //$mail-&gt;AddAttachment("images/phpmailer.gif");      // attachment
      //$mail-&gt;AddAttachment("images/phpmailer_mini.gif"); // attachment
  
      if(!$mail-&gt;Send()) {
      echo "Mailer Error: " . $mail-&gt;ErrorInfo;
      } else {
        echo "Message sent! Thank you for your feedback.";
       }
      }
      else {
      echo "data is empty";
       }
      ?&gt; `
  </code></pre>