Clearing Postfix Mail Queues
I'm having a little problem with writing a script to clear e-mails in the postfix queue that have the error "Domain Not Found.".
My scripting skills aren't great by any means and the problem I'm having is when searching for this error message it's on a seperate line from the Queue ID, so how do I get the line above it to return as well? For example...
5CAE47705F 4803 Wed Nov 21 15:12:54 email@example.com
(host mail.server[127.0.0.1] said: 450 4.1.2 <firstname.lastname@example.org>: Recipient address rejected: Domain not found (in reply to RCPT TO command))
I've tried thinking of various grep combinations, and/or using xargs somehow, but can't manage to get the line above the one that's been returned when grep'ing for said error message! Any help would be much appreciated, thanks! :)