How to change smtp port number 25 in postfix

Bydefault the SMTP protocol runs at port no. 25.
You can change the port no. to any port no. other than below 2048.
0 to 2048 are IANA authorized known port no.but we have some other port no. also which are bydefault used by manyapplication for. eg. port no. 8080 for tomcat.
To know more about port number click this wikipedia URL .

Here we are using Postfix as our MTA.
To change the smtp port no. in postfix,edit the master.cf file and change the given below value

vi /etc/postfix/master.cf
smtp inet n – n – – smtpd

change smtp word to your desired port no. Here I am changing it to 9267

9267 inet n – n – – smtpd

Now restart the postfix

/etc/init.d/postfix restart

Check the port no. status with netstat command

[root@localhost postfix]# netstat -tanp|grep 9267
tcp 0 0 0.0.0.0:9267 0.0.0.0:* LISTEN 9788/master
[root@localhost postfix]#

Read Some More Articles

7 Comments

  1. Thanks you
    That part is OK thanks you again. But then I have other problem

    Dec 12 14:36:43 localhost postfix/smtp[3596]: connect to mail.example.com[1.1.1.1]:25: Connection timed out

    25: Connection timed out
    How I can to do. What do you believe?
    UDP and SMTP (port 25) may also be blocked. Maybe operating system is configured with firewalls which block traffic. Is possible to open port within my VPS’s firewall.

    1. Hello Armando,

      It is related to no connection blocked either by network firewall or iptables of client/server.
      You have to allow mail port from firewall and iptables.

      Regards
      Sharad

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.