title: Sending email over Office365 account in Codeigniter 3 - connection timeout
body: <p>I'm trying to connect to my Office365 account and send out an email in Codeigniter 3:</p>
  
  <pre><code>$config['protocol'] = 'smtp';
  $config['smtp_host'] = 'smtp.office365.com';
  $config['smtp_user'] = '****';
  $config['smtp_pass'] = '****';
  $config['smtp_port'] = '587';
  $config['smtp_timeout'] = '60';
  $config['smtp_crypto'] = 'tls';
  $config['mailtype'] = 'html';
  $this-&gt;email-&gt;initialize($config);
  
  $this-&gt;email-&gt;from('****', '****');
  $this-&gt;email-&gt;to('****');
  
  $this-&gt;email-&gt;subject('Email Test');
  $this-&gt;email-&gt;message('Testing the email class.');
  
  $this-&gt;email-&gt;send(FALSE);
  
  $this-&gt;email-&gt;print_debugger();
  </code></pre>
  
  <p>This code works fine on my local server (wamp), but not on my production server (Debian), that's why I suspect some settings on the server need to be altered. All I get is this:</p>
  
  <pre><code>A PHP Error was encountered
  
  Severity: Warning
  
  Message: fsockopen(): unable to connect to smtp.office365.com:587 (Connection timed out)
  
  Filename: libraries/Email.php
  
  Line Number: 1949
  </code></pre>
  
  <p>I also tried sending mail with Phpmailer class and I got the same result; works on my local machine, not on production server.</p>
  
  <p>Codeigniter class uses function fsockopen to connect to the mail server, but I can't find out the solution, since I don't know much about server configuration.</p>
  
  <p>Any suggestion would be appreciated!</p>