title: How can I check if ports 465 and 587 are open with PHP?
body: <p>I'm trying to use PHPMailer to send e-mails with SMTP and gmail. The exact script am using works on other servers but it is not working on this particular hosting company's server.</p>
  
  <p>I have checked the <code>phpinfo()</code> and it tells me that <code>allow_url_fopen</code> is  <code>on</code> and there are no <code>disabled_functions</code> like <code>fopen</code> listed.</p>
  
  <p>The script fails and it tells me either:</p>
  
  <pre><code>SMTP -&gt; ERROR: Failed to connect to server: Connection timed out (110) 
  </code></pre>
  
  <p>or else</p>
  
  <pre><code>SMTP Error: Could not authenticate.
  </code></pre>
  
  <p>I'm assuming this is because it can not connect, because again this work on other servers and the authentication credentials are correct.</p>
  
  <p>So I ask more generally, is there a way I can use PHP or jailshell <code>ssh</code> to check and see if the ports are actually open or not?</p>