TL;DR: can I DISCARD
outgoing mail to a specific server by DNS name of the MX record , or failing that, by its IP?
We've some 'trouble' (well, more of an annoyance really), of people filling out some random keyboard strokes as e-mail address. Suprise surprise: most of those @hjk.tld & @asdf.tld domains are parked domains for sale. Generally, per tld, there are only 1 to 3 players having claimed the bulk of these domains. Usually, they've configured the same MX record for those domains, but are either not listening on it or denying sending any e-mail on it.
Those e-mails just hang there in the queue, will never be delivered, and bounce back after a the final time-out. That server has better things to do, so I'd like to discard those e-mails immediately. I could list every single one of those domains in a blacklist, but (a) that would mean that when the domain actually is sold / becomes active, mail is discarded unjustly and (b) maintaining that list is a pain.
What I would very much like, is a way in Postfix to list any mail for which the mx server is 'some-mx.somedomainparker.tld' as a reason to discard the mail at the first possible point. If it can't be done based on DNS name, perhaps based on its IP. I can't seem to find anything like that in de docs. Of course, I could just drop traffic to the specific IP, keeping resources used to a minimum, but I'd like to keep my queues as clean as possible.
You can either use a bespoke script of your own involving mailq pipes, sed ,awk and postsuper. Or you can install and use pfqueue, which will allow you to tag mails for further actions, like delete or hold.
I understand what you're trying to do, but honestly, it's an irresponsible course of action for a mail system administrator. What happens when those MXes start accepting mail for a domain your users are trying to email? Their messages will be silently dropped. Not a good outcome.
Instead of discarding the messages, why not just shorten the queue/retry period on these messages? That will keep your queues cleaner than before, without completely breaking how email delivery is supposed to work (and how users expect it to work).