Hello, we get a lot of mailer daemons due to an email coming in to a non existent user, so then an email is returned to sender to say the user does not exist, but if that reply to email is bogus, the email gets stuck in the queue. So i figure any emails that are stuck in the queue for over and hour for sure are probably no legit. I want to delete these emails automatically. Any ideas? like run a script every hour to delete old emails in the queue? Thanks
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } /MAILER-DAEMON/ { print $1 }' | tr -d '*!' | postsuper -d - removes all mails for MAILER-DAEMON from the queue