title: Codeigniter & PHPMailer
body: <p>So I've been trying this for a day or two now. At first, I tried the built in codeigniter SMTP mail class, with no luck. In hope of fixing this problem, I turned to PHPMailer. And to my disappointment, there is still no luck.</p>
  
  <p>I'm certain that all details are correct. I've even tried multiple SMTP servers, those of which include gmail and mandrill.</p>
  
  <p>Here's the code that I am using (I have tried many different modified versions of this, but I'll give you the one that I'm currently using)</p>
  
  <pre><code>&lt;?php
  
  class thankyou extends CI_Controller {
  
  function index()
  {
  
      $this-&gt;load-&gt;model('index');
  
      $header = array(
          'title' =&gt; 'Please Confirm',
          'navigation' =&gt; $this-&gt;index-&gt;loadNavigation(),
      );
  
      $this-&gt;load-&gt;view('header', $header);
  
      $this-&gt;load-&gt;library('My_PHPMailer');
  
      $mail = new PHPMailer();
      $mail-&gt;IsSMTP();                                      // Set mailer to use SMTP
      $mail-&gt;Host = 'smtp.mandrillapp.com';                 // Specify main and backup server
      $mail-&gt;Port = 587;                                    // Set the SMTP port
      $mail-&gt;SMTPAuth = true;                               // Enable SMTP authentication
      $mail-&gt;Username = 'email@outlook.com';                // SMTP username
      $mail-&gt;Password = 'password4mandrill';                  // SMTP password
      $mail-&gt;SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted
      $mail-&gt;SMTPDebug = 1;
  
      $mail-&gt;From = 'hello@whatever.co.uk';
      $mail-&gt;FromName = 'Whatever';
      $mail-&gt;AddAddress('hello@whatever.co.uk', 'Josh Adams');  // Add a recipient              // Name is optional
  
      $mail-&gt;IsHTML(false);                                  // Set email format to HTML
  
      $mail-&gt;Subject = 'Here is the subject';
      $mail-&gt;Body    = 'This is the HTML message body &lt;strong&gt;in bold!&lt;/strong&gt;';
      $mail-&gt;AltBody = 'This is the body in plain text for non-HTML mail clients';
  
      if(!$mail-&gt;Send()) {
         echo 'Message could not be sent.';
         echo 'Mailer Error: ' . $mail-&gt;ErrorInfo;
         exit;
      }
  
  }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>If need be, you can <a href="http://producerdesign.co.uk/thankyou" rel="nofollow">Test it here</a></p>
  
  <p>I just get the error <code>2014-06-09 11:18:40   SMTP ERROR: Failed to connect to server: Connection timed out (110) SMTP connect() failed. Message could not be sent.Mailer Error: SMTP connect() failed.</code></p>