testing mail server from WAN

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DaveKimble
Forum Newbie
Posts: 3
Joined: Thu Mar 08, 2012 6:21 pm

testing mail server from WAN

Post 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 ?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: testing mail server from WAN

Post 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.
DaveKimble
Forum Newbie
Posts: 3
Joined: Thu Mar 08, 2012 6:21 pm

Re: testing mail server from WAN

Post 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 ?
DaveKimble
Forum Newbie
Posts: 3
Joined: Thu Mar 08, 2012 6:21 pm

Re: testing mail server from WAN

Post 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.
Post Reply