I've been tasked with catching several bounce-back conditions (no longer subscriber, connection refused, host not found, email address invalid, etc) and adding the offending email address from our email server's messaging list to prevent poisoning our mailserver's IP per several ISPs rules.
Messages in my deferral queue are set to be removed after 5 days and I have been instructed to catch the above stated conditions after 3 days to auto-opt-out. I have a kludgy method for doing this but I don't believe it's an ideal solution. Is there anything built in to Postfix to automate this process better? Currently I am iterating through messages from `postqueue -p` with grep and awk to parse out emails that match the conditions specified and log the timestamp and the offending email address. I am then looping though the generated hashmap to run a SQL insert on email addresses that have been in the queue for more than 3 days. Obviously this process isn't ideal and is prone to false-positives. Does anyone have experience implementing something similar in a more intelligent manor?