title: CodeIgniter: SSL/TLS SMTP Auth Email from PHPMailer Code
body: <p>I'm trying to use the CodeIgniter Email Class to write a secure SMTP email; either SSL or TLS (preferred). In the past, I've successfully used PHPMailer with Secure Auth and TLS. I believe it was a secure connection. TLS shows up in the email header.</p>
  
  <p>Does CodeIngiters' Email Class support secure SMTP authentication with TLS?</p>
  
  <p>Note, this is not a Gmail question. I'm trying to use it with an MS Exchange Server. I've confirmed the PHPMailer code below functions correctly.</p>
  
  <pre><code>include_once('includes/class.phpmailer.php');
  $mail = new PHPMailer(true);
  $mail-&gt;IsSMTP();
  $mail-&gt;Host = 'www.domain.com';
  
  $mail-&gt;SMTPAuth = true;
  $mail-&gt;SMTPSecure = "tls";
  $mail-&gt;Port     = '25';
  $mail-&gt;Timeout  = '60';
  
  $mail-&gt;Username = 'user@domain.com';
  $mail-&gt;Password = 'password';
  
  $mail-&gt;From     = 'alerts@domain.com';
  $mail-&gt;FromName = 'Alerts';
  
  $mail-&gt;Subject  = 'Test from test email file.';
  $mail-&gt;IsHTML(true);
  $mail-&gt;MsgHTML('This is just a test.');
  
  // To
  $mail-&gt;AddAddress('alerts@domain.com', 'Research');
  $result = $mail-&gt;Send();
  </code></pre>
  
  <p>With CodeIgniter I've already extended the Email Class (MY_Email.php). The class is a bit big to post here. But, here's the error I keep getting.</p>
  
  <p>Settings:</p>
  
  <pre><code>array(7) { 
  ["smtp_host"]=&gt; string(26) "tls://www.domain.com" 
  ["smtp_port"]=&gt; string(2) "25" 
  ["smtp_user"]=&gt; string(17) "alerts@domain.com" 
  ["smtp_pass"]=&gt; string(9) "password" 
  ["smtp_to_email"]=&gt; string(26) "user@domain.com" 
  ["smtp_from_email"]=&gt; string(26) "user@domain.com" 
  ["smtp_from_name"]=&gt; string(24) "Test from Application" 
  }
  </code></pre>
  
  <p>Error Message:</p>
  
  <blockquote>
    <p>fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:1408F10B:SSL routines:func(143):reason(267)</p>
  </blockquote>
  
  <p>Any idea what reason 267 is?</p>