title: Failed to send AUTH LOGIN command. Error: Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method
body: <p>I'm trying to send a email from Office 365 using PHP Code-Igniter. <strong>But I got an error:</strong></p>
  
  <blockquote>
    <p>220 MAXPR0101CA0041.outlook.office365.com Microsoft ESMTP MAIL Service
    ready at Tue, 26 Dec 2017 11:17:56 +0000 </p>
    
    <p>hello: 250-MAXPR0101CA0041.outlook.office365.com Hello [115.96.169.89]</p>
    
    <p>250-SIZE 157286400</p>
    
    <p>250-PIPELINING</p>
    
    <p>250-DSN</p>
    
    <p>250-ENHANCEDSTATUSCODES</p>
    
    <p>250-STARTTLS</p>
    
    <p>250-8BITMIME</p>
    
    <p>250-BINARYMIME</p>
    
    <p>250-CHUNKING</p>
    
    <p>250 SMTPUTF8</p>
    
    <p>Failed to send AUTH LOGIN command. Error:  504 5.7.4 Unrecognized
    authentication type [MAXPR0101CA0041.INDPRD01.PROD.OUTLOOK.COM] </p>
    
    <p>Unable to send email using PHP SMTP. Your server might not be
    configured to send mail using this method.</p>
    
    <p>Date: Tue, 26 Dec 2017 12:17:56 +0100</p>
    
    <p>From: </p>
    
    <p>Return-Path: </p>
    
    <p>To: myemail@mydomain.com</p>
    
    <p>Subject: =?UTF-8?Q?Test=20Email?=</p>
    
    <p>Reply-To: </p>
    
    <p>User-Agent: CodeIgniter</p>
    
    <p>X-Sender: myemail@mydomain.com</p>
    
    <p>X-Mailer: CodeIgniter</p>
    
    <p>X-Priority: 3 (Normal)</p>
    
    <p>Message-ID: &lt;5a422fe430795@mydomain.com></p>
    
    <p>Mime-Version: 1.0</p>
    
    <p>Content-Type: multipart/alternative; boundary="B_ALT_5a422fe4307e9"</p>
    
    <p>This is a multi-part message in MIME format. Your email application
    may not support this format.</p>
    
    <p>--B_ALT_5a422fe4307e9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit</p>
    
    <p>SMTP sending test email, Done...</p>
    
    <p>--B_ALT_5a422fe4307e9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable</p>
    
    <p>SMTP sending test email, Done...</p>
    
    <p>--B_ALT_5a422fe4307e9--</p>
  </blockquote>
  
  <p><strong>Here is my Controller code:</strong></p>
  
  <pre><code>public function emailSend()
      {
          # code...
          /*
          Minimun test code for successful email sending over SMTP with Office 365
          Things to double-check: 
          - openssl php extension must be enabled in the server
          - host set to smtp.office365.com, not the old aliases
          - Port 587
          - newline configuration: explicit to "\r\n"
          */
  
          //In your Controller code:
  
          $this-&gt;load-&gt;library('email');        
  
          //$config = [
              $config['protocol']= 'smtp';
              $config['mailpath']= "/usr/lib/sendmail";
              $config['smtp_port']= 587;
              $config['smtp_timeout'] = '7';
              $config['smtp_host']= 'smtp-mail.outlook.com';
              $config['smtp_user']= 'myemail@mydomain.com';
              $config['smtp_pass']= '*********';
              $config['smtp_crypto']= 'STARTTLS';   
              $config['newline']= "\r\n"; //REQUIRED! Notice the double quotes!
              $config['crlf']= "\r\n";
              $config['mailtype'] = 'html';
          //];
  
          $this-&gt;email-&gt;initialize($config);
  
          $this-&gt;email-&gt;from('myemail@mydomain.com');        
          $this-&gt;email-&gt;to('myemail@mydomain.com');
          $this-&gt;email-&gt;subject('Test Email');
          $this-&gt;email-&gt;message('SMTP sending test email, Done...');
  
          $sent = $this-&gt;email-&gt;send();
  
  
          if ($sent) 
          {
              echo 'OK';
  
          } else {
              echo $this-&gt;email-&gt;print_debugger();
          }
  
      }
  </code></pre>
  
  <p>I had check lots of links and questions, but no success. I'm not getting what is exact error in code.</p>
  
  <p><strong>Note:</strong>
  I'm tried </p>
  
  <pre><code>$config['smtp_port']= 465; 
  $config['smtp_crypto']= 'TLS';
  $config['smtp_crypto']= 'SSL';
  </code></pre>
  
  <p>Any kind of help is welcome, thanks in advance.</p>