CentOS 8.x postfix send email via other relayhost or smarthost without using port 25
<yambe:breadcrumb self="Send email via other relayhost or smarthost without using port 25">CentOS 8.x postfix|postfix</yambe:breadcrumb>
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:
- 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
- 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
- On mail.sbarjatiya.com edit main.cf add public IP of mail.example.com in mynetworks with /32 mask
- Then restart postfix on mail.sbarjatiya.com using:
- systemctl restart postfix
- Validate that system is now listing on port 2525 also
- ss -alnp | grep 2525
- 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
- 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
- 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
- Send a few test emails from mail.example.com and validate.
<yambe:breadcrumb self="Send email via other relayhost or smarthost without using port 25">CentOS 8.x postfix|postfix</yambe:breadcrumb>