title: Unable to send mail with PHP (phpmailer) via Office365 in Hostgator. How to fix this?
body: <p>I want to be able to send mails in <a href="http://www.hostgator.com/shared.shtml" rel="nofollow noreferrer">Hostgator</a> via office365. I was able to do it with Gmail, but can not set it up to work with office365.</p>
  
  <p>It works on my 2 other servers. The only problem is Hostgator.</p>
  
  <p>Do I have to fix something or Hostgator have to take some action?</p>
  
  <pre><code>&lt;?php
  require_once('class.phpmailer.php');
  $mail = new PHPMailer(true);
  
  
  
  $mail-&gt;IsSMTP();
  
  $mail-&gt;SMTPDebug = 2;
  $mail-&gt;SMTPAuth = true;
  $mail-&gt;SMTPSecure = "tls";
  $mail-&gt;Host = "pod51014.outlook.com";
  $mail-&gt;Port = 587;
  $mail-&gt;Username = "usernamehere";
  $mail-&gt;Password = "************";
  
  /* ... addaddres, reply, subject, message -&gt; the usual stuff you need ... */
  
  $mail-&gt;Send();
  
  ?&gt;
  </code></pre>
  
  <p>I just keep getting following response:</p>
  
  <pre><code>SMTP -&gt; ERROR: Failed to connect to server: Connection refused (111) 
  </code></pre>
  
  <p>I was on the support chat with them and the 587 port should be open.</p>