title: PHP smtp.office365.com for email
body: <p>Is it possible to make PHP application mail integrated with Office365?</p>
  
  <p>I have tried but found this error :</p>
  
  <pre><code>authentication failure [SMTP: SMTP server does not support authentication (code: 250, response: SINPR02CA025.outlook.office365.com Hello [17*.***.***.**] SIZE 78643200 PIPELINING DSN ENHANCEDSTATUSCODES STARTTLS 8BITMIME BINARYMIME CHUNKING)]
  </code></pre>
  
  <p>and my PHP code so far :</p>
  
  <pre><code>$host = "smtp.office365.com";
  $username = "me@company.com";
  $password = "example";
  
  $headers = array(
      'From'          =&gt; $from,
      'To'            =&gt; $to,
      'Subject'       =&gt; $subject,
      'Content-Type'  =&gt; 'text/html; charset=UTF-8'
  );
  
  $recipients = $to.", ".$bcc;
  
  $smtp = Mail::factory('smtp',
      array ('host' =&gt; $host,
      'auth' =&gt; true,
      'username' =&gt; $username,
      'password' =&gt; $password));
  
  $mail = $smtp-&gt;send($recipients, $headers, $body);
  </code></pre>