Page 1 of 1

testing mail server from WAN

Posted: Thu Mar 08, 2012 6:29 pm
by DaveKimble
I have a mail server running live on localhost, POP3/IMAP/SMTP with SSL.
I need to check occasionally whether it is on-line from the WAN side of the network.
So I wrote a PHP script that connects to port 465 and gets the welcome message,
and FTP'd it to a remote web server, and invoked it from my browser on localhost.

Code: Select all

<?php
$transport = 'ssl://' ;
$host = 'mail.mydomain.com';
$port = 465;
$timeout = 5;
$server = fsockopen($transport . $host, $port, $errno, $errstring, $timeout);
if ($server) { echo fgets($server, 80); fclose($server);} 
else { echo ( 'Failed ' . $errno . ' ' . $errstring ) ; }
?>
and it works OK.
Then I tried it with $port = 995 and 993.
And it doesn't connect - "Failed 110 Connection timed out".

The hostname is right.
I have tried replacing it with the IP address.
The port numbers are right.
The router's ports are open to WAN.
I have tried a longer timeout.
I have monitored the connections with TCPView and during the test nothing connects for 995 and 993,
though its a live server and users are connecting with email clients all the time.

What am I doing wrong ?

Re: testing mail server from WAN

Posted: Thu Mar 08, 2012 7:14 pm
by Celauran
Have you ensured that those ports aren't being blocked by your ISP? I need to use 8080 to connect to my Apache machine from outside.

Re: testing mail server from WAN

Posted: Thu Mar 08, 2012 7:43 pm
by DaveKimble
its a live server and users are connecting with email clients all the time.

Could the host of the remote web server where the script is running prevent me accessing some ports ?

Re: testing mail server from WAN

Posted: Wed Mar 21, 2012 10:32 pm
by DaveKimble
I have prettied the thing up so it does a few more tests, but it still fails on 993 and 995:

Code: Select all

PHP version 5.2.17
Testing xxxxx mail server
13:16:33 xxxxx.org.au MX records mail.xxxxx.org.au
13:16:34 mail.xxxxx.org.au IP ad  xxx.xxx.93.92
13:16:34 ssl://xxx.xxx.93.92:993 110 Connection timed out
13:16:39 ssl://xxx.xxx.93.92:995 110 Connection timed out
13:16:44 ssl://xxx.xxx.93.92:465 220 xxx-xxx-93-92.static.dsl.dodo.com.au
13:16:46 Waiting 5 minutes ...

Any ideas welcome.