title: Checking Open Ports PHP
body: <p>I am having issues sending mail using SMTP from a shared web server (Apache), although it works on my localhost (XAMPP) environment.</p>
  
  <p>I've been advised (by other people that had similar issues) to check if the remote web server has the port 587 opened and available.</p>
  
  <p>The code I am using is below;</p>
  
  <pre><code>    $fp = fsockopen("smtp.office365.com", 587, $errno, $errstr, 5); 
      if (!$fp)
          echo "smtp.office365.com 587  -  $errstr   ($errno)&lt;br&gt;\n";
      else
          echo "smtp.office365.com 587 -  ok&lt;br&gt;\n";
  </code></pre>
  
  <p>When I run this <strong>locally</strong> I see the following message;</p>
  
  <blockquote>
    <p>smtp.office365.com 587 - ok</p>
  </blockquote>
  
  <p>When I run this on the <strong>remote</strong> server I see;</p>
  
  <blockquote>
    <p>smtp.office365.com 587 - Connection timed out (110)</p>
  </blockquote>
  
  <p>Along with the PHP error;</p>
  
  <blockquote>
    <p>Message: fsockopen(): unable to connect to smtp.office365.com:587
    (Connection timed out)</p>
  </blockquote>
  
  <p>So. it looks like I <em>can</em> connect via my localhost, but <em>can't</em> via the remote host.</p>
  
  <p>My question is, what does this mean exactly? And is there anything I can suggest to my web host that they need to configure or check? They are convinved there is an error in my code, however I feel that the issue is at their end - not sure how I can convince them of this :/</p>
  
  <p>Thanks</p>