Search left

How to run the SMTP server on another port



The problem: Many ISP’s block port 25 for outgoing mail. So if you are running a Linux/Unix Plesk based server (or, in fact, any kind of SMTP server), your clients can be in a situation where they can receive mail (POP3/110) from your server, but they can’t send mail (SMTP/25) from their mail client using your server.
Note: Generally, the ISP will “kindly” give you the opportunity to use their SMTP/IMAP server, but this can be a risk.

Solution 1: Tell you clients to use Plesk’s Webmail. Or not … and skip to the second solution :)

Solution 2: Use another port for the SMTP server, keeping the server to accept connections on standard port 25.
In this way, the SMTP / Plesk’s Qmail server will accept connections on two different ports, using a simple port redirection. We’ll use one iptables rule, with 587 as the second port, like this:

sudo iptables -t nat -A PREROUTING -p tcp --dport 587 -i eth0 -j REDIRECT --to-ports 25

Also, it would be a good idea to add this to add it to system startup or to your firewall, to avoid loosing these settings after reboot.
For example, on any Debian based system, you can add it to /etc/rc.local:

sudo echo "# Port redirection from port 587 to 25, on eth0
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 587 -i eth0 -j REDIRECT --to-ports 25" >> /etc/rc.local

Notes:
1: You can choose any other port, replace 587 with the port you want to use.
2: Don’t forget to open this port in your firewall.
3. Don’t forget to tell your clients about this, and maybe … be a sport and give them a helping hand in the long process of configuring the mail client :D

Have fun playing …


Tags: , , , , , , ,



This entry is filed under Debian, Linux, Plesk.



Leave a Reply




 



Footer left Footer right