How to Change the Port Number in Postfix

The default network SMTP port for Postfix, Sendmail and most other mail servers is 25. This is the port used to send email, and most email clients will use it by default. Unfortunately, some Internet service providers have started to block port 25 because of the high volume of spam sent through it. For SMTP, they require their users to use the ISP’s SMTP.

This is a the primary reason why server administrators might change their SMTP port, but there are others. Some server administrators use proxy servers to redirect mail traffic through SPAM and DNS filters before eventually resolving to another port. Others change it, for security purposes, to a port that is more difficult for spammers and hackers to guess.

To change your Postfix port, you will need to have root access to your server. Edit the Postfix configuration file: /etc/postfix/ and comment out the following line:

# smtp innet n - n - - smtpd

(Code can be commented out by placing the “#” sign in front of a line)

Next, add this line:

7538 inet n - n - - smtpd

Replace “7538” with whatever port you prefer to use for your SMTP server.

Finally, restart Postfix:

/etc/init.d/postfix restart OR service postfix restart

If you are using a software firewall, you will need to configure it to allow the new port and deny port 25. After that, you are all finished. Do not forget to inform any users will mail accounts that they will need to send mail through the new port.