Fairly new to Postfix.
I have Postfix setup for SMTP relay to Office365 and we are needing to set specific internal hosts to only email specific domains, e.g.
server1-->example.comonly. Deny allserver2-->example.comonly. Deny all
We want to maintain the ability for all other internal hosts to not have this restriction, e.g.
server3-->example.comexample.netAllow allserver4-->example.comexample.netAllow all- (Many other servers)
Rationale behind this is we want server1 and server2 to only send internally, but all other servers will utilize the relay without limitation.
My first approach was the following (partial of main.cf):
smtpd_relay_restrictions =
check_client_access,
hash:/etc/postfix/blacklist,
permit_mynetworks,
permit_sasl_authenticated,
defer_unauth_destination
myhostname = example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = smtp_relay.example.com
mydestination =
The /etc/postfix/blacklist has the following:
server1.example.com REJECT Blocked for a good reason
server2.example.com REJECT Blocked for a good reason
server1 REJECT Blocked for a good reason
server2 REJECT Blocked for a good reason
192.16.1.10 REJECT Blocked for a good reason
192.16.1.11 REJECT Blocked for a good reason
This blocks all traffic from server1 and server2; all traffic from other hosts work without issue.
The need is to block all traffic from these servers, except if sending to example.com., and maintain the ability for all traffic from other hosts to work without issue.
Any direction on where to look and config testing is always appreciated.