Changing Postfix from port 25 to port 587

I just installed Rockylinux 9,2 on a PC. It’s been a long time ( I’m retired) since I was a linux sysop.

I’ve a problem. I’m trying to configure Postfix as a mail MTA. I have it running and it will forward local mail. The problem is that it’s listening, by default, to port 25. Myt ISP blocks port 25 and uses port 587,

I’ve looked on line, tried all the changes in and and none work. How can I get postfix to use port 587 for both inbound and outbound emails?


I do not think doing this is a good idea and it may not work the way you think it’s going to work. You are banking on other MTA’s being aware that port 587 is for both incoming and outgoing mail, and this is generally never the case. You cannot define this in DNS MX records, because anything dealing with mail is aware of and supports 25.

For context, port 25 is for communication between mail servers (this means MTA to MTA or MSA to MTA). Port 587 is for submission of outgoing mail by a mail client (mail user agent).

My suggestion is that you find a way to stand up a relay server somewhere that is configured to be aware of where to send mail to and on what port to your home system.

With all that said, you can get postfix to listen on 587 without much of a fight.

[root@xmpp01 ~]# ss -tuna | grep -E '25|587'
tcp   LISTEN 0      100                   *
tcp   LISTEN 0      100                      [::1]:25                        [::]:*
[root@xmpp01 ~]# vi 's/^smtp /587 /g' /etc/postfix/
[root@xmpp01 ~]# systemctl restart postfix
[root@xmpp01 ~]# ss -tuna | grep -E '25|587'
tcp   LISTEN 0      100                  *
tcp   LISTEN 0      100                      [::1]:587                       [::]:*

Alternatively, you can copy the “smtp” line and make postfix listen on both.

smtp      inet  n       -       n       -       -       smtpd
587      inet  n       -       n       -       -       smtpd
1 Like

The port 25 restriction is for both inbound and outbound traffic. My ISP blocks port 25 in their gateway routers as well as in their relay mail servers.

I’ve done this and postfix still listens only on port 25, nor with the relay server.


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.