An app on our server allowed customers to pick whatever FROM address they wanted for their email alert including domain. This completely skewed our statistics over at Sparkpost as we attempted to send emails from unverified domains like a.com, none.com, dont.care etc.
I was growing tired of waiting for the developers to move their ass so I decided to step in. This is how you limit your outbound emails to specific domains:
!/(^From:.*domain\.com|^From:.*domain\.net|^From:.*domain\.co\.il)/ DISCARD SEND FROM THE RIGHT DOMAINS ASSHOLE
header_checks = pcre:/etc/postfix/header_checks
Restart or reload Postfix.
And there you have it.
All emails should be of either of domain.com, domain.co.il or domain.net.
The rest will be scrapped.