CentOS 8.x postfix send email via other relayhost or smarthost without using port 25

From Notes_Wiki

Home > CentOS > CentOS 8.x > CentOS 8.x email servers > CentOS 8.x postfix > CentOS 8.x postfix send email via other relayhost or smarthost without using port 25

Same as explained at CentOS 7.x Zimbra add additional ports for SMTP service when outgoing port 25 is blocked which internally uses postfix, without Zimbra also two postfix servers can be configured such that a server whose outgoing port-25 communication is restricted can send all its emails via other server. In this case communication between two servers can happen without depending on port 25.

Lets say mail.example.com outgoing port 25 is blocked and hence they want to send emails via mail.sbarjatiya.com using mail.sbarjatiya.com as smarthost / relayhost. Then for that use following steps:

  1. On mail.sbarjatiya.com firewalld and other network firewall allow access to some other port (eg 2525).
    firewall-cmd --zone=public --add-port=2525/tcp --permanent
    firewall-cmd --reload\
    firewall-cmd --zone=public --list-all
  2. On mail.sbarjatiya.com edit /etc/postfix/master.cf by copying
    smtp inet n - n - - smtpd
    and pasting it back as
    2525 inet n - n - - smtpd
    You can add comments starting with # before the new line to explain purpose of making smtpd listen additionally on port 2525
  3. On mail.sbarjatiya.com edit main.cf add public IP of mail.example.com in mynetworks with /32 mask
  4. Then restart postfix on mail.sbarjatiya.com using:
    systemctl restart postfix
  5. Validate that system is now listing on port 2525 also
    ss -alnp | grep 2525
  6. From mail.example.com try to connect to mail.sbarjatiya.com on port 2525 and validate things are working as expected
    nc mail.sbarjatiya.com 2525
  7. Then on mail.example.com edit /etc/postfix/main.cf and mention mail.sbarjatiya.com with port 2525 as relayhost
    relayhost = mail.sbarjatiya.com:2525
  8. Ideally update SPF records of mail.example.com (example.com domain) to include:
    a:mail.sbarjatiya.com
    to indicate that emails for example.com domain can come from A address of mail.sbarjatiya.com
  9. Send a few test emails from mail.example.com and validate.



Home > CentOS > CentOS 8.x > CentOS 8.x email servers > CentOS 8.x postfix > CentOS 8.x postfix send email via other relayhost or smarthost without using port 25