Postfix reject client from domains without MX records

emailemail-serverpostfix

Machine mail.domain.com send email for domain.com through Postfix 2.11 but today reviewing mail.log file i noticed some WordPress on machines wordpress.domain.com and blog.domain.com as sending email through mail.domain.com where sender address is user@wordpress.domain.com and user@blog.domain.com. Obviously they configured WordPress to authenticate and send email to mail.domain.com.

The issue here is mail.domain.com is responsible of sending email for domain.com but not *.domain.com so the latter are not DKIM signed and obviously are not valid recipient addresses as those domains are not able to recieve email so i would like to reject clients using a from domain address which is not able to receive email like *.domain.com.

I've been looking at the docs http://www.postfix.org/postconf.5.html but i'm unable to find a neat solution. Does anyone know how can i accomplish that?

Thanks a lot

Best Answer

You can achieve it with parent_domain_matches_subdomains and smtpd_sender_restrictions. Add the following to your main.cf

#/etc/postfix/main.cf
#...
parent_domain_matches_subdomains =
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_blacklists
#...

#/etc/postfix/sender_blacklists
domain.com      OK
.domain.com     REJECT

Ref: postfix access Readme

Related Topic