Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Changing SMTP ports in Linux  (Read 3368 times)

0 Members and 1 Guest are viewing this topic.

joseletk

  • Guest
Changing SMTP ports in Linux
« on: June 09, 2018, 06:46:57 pm »
Due to a very large volume of junk email being produced today, most ISPs now block port 25. By default, your server may use port 25 to send mail; as a result, you could find that your email is being blocked. After completing the operations below, don't forget to restart your mail server!

Exim

If you have WHM/cPanel, you can simply go into Service Manager and change the port there. Be sure to enable 'Exim on Another Port'.

Otherwise, modify the following file, using your favourite text editor:

Code: [Select]
    /etc/exim.conf
You will need to add these lines, replacing 26 by 587 if desired:

Code: [Select]
daemon_smtp_ports = 26
acl_smtp_rcpt = check_recipient
acl_smtp_data = check_message

Postfix

You will need to edit the following file:

Code: [Select]
/etc/postfix/master.cf
Add a line to the file in the following format:

Code: [Select]
<port> inet n - - - - smtpd
Replace <port> with the appropriate port number, for example:

Code: [Select]
26 inet n - - - - smtpd
QMail

You will need to modify the following file:

Code: [Select]
/etc/services
Add the following line, replacing the <port> with the actual port:

Code: [Select]
smtp_alt <port>/tcp # new SMTP port
If you are running xinetd as a super-server, you will need to follow these extra instructions:

First, make a backup copy of smtp_psa by using this command:

Code: [Select]
cp /etc/xinetd.d/smtp_psa /root/smtp_psa.backup
Everything located in /etc/xinet.d/ is loaded as xinet services.

Next, edit the file /etc/xinetd.d/smtp_psa and add the following line:

Code: [Select]
service smtp_alt
Then restart xinetd using the following command:

Code: [Select]
/tc/init.d/xinetd restart
If that does not work, you can use iptables to make the modification:

Change the IP in the following file:

Code: [Select]
/var/qmail/control/outgoingip
Then execute this command:

Code: [Select]
/sbin/iptables -t nat -A POSTROUTING -o eth0 -p tcp --dport 25 -j SNAT --to $(< /var/qmail/control/outgoingip) >> /etc/rc.local
Verify you are still able to send emails. If not, just remove this line from /etc/rc.local/


======================================================================