Why is my Linux email system failing to send email messages with a "Connection timed out (port 25)" message in the maillog file?
This is an increasing common problem so it is worth discussing this in a little detail here.
Email is transmitted and received over the internet using the SMTP protocol and this communication takes place between the sender and the receiving server over port 25.
Having set up the email system on your Linux server you may find that email messages you are trying to send never reach their destination. The first thing to check in this situation is the mail system log file (/var/log/maillog) on mosts systems. For each attempt to send a message you may something like the following:
Apr 28 13:37:55 localhost postfix/smtp:
connect to gmail-smtp-in.l.google.com[18.104.22.168]: Connection timed out (port 25)
What this tells us is that the mail system was unable to connect to the desintation server uysing port 25
This problem is almost always caused by the fact that the Internet Service Provider (ISP) to which you system gets in internet connection has decided to block port 25. ISPs often do this these days in an attempt to control the amount of spam that is being sent by some of their more unscupulous customers. In effect they are trying to contribute to reducing the level of spam on the internet but in doing so cause problems for the innocent.
The easiest solution to the problem (and also what your ISP wants you to do) is relay your outgoing mail via their mail servers rarther than sending it direct to the destination server.
Assuming you are using Postfix for your email system you can achieve this by chaning the /etc/postfix/main.cf file and setting the relayhost entry to the appropriate mail server provided by your ISP (you can usually figure this out from the errors in your mail log or by contacting your ISP). For example, for a sever that is connect to Bellsouth DSL the relayhost entry might read:
relayhost = [mail.bellsouth.net]
It my then be necessary to restart you Linux mail server as follows (once again assuming you are using Postfix):
/sbin/service postfix restart
You should now find that when you send email it is now successfuly relayed via your ISPs servers