#!/usr/bin/perl -w # # file: remove-bounce-emails.pl # purpose: remove bounce emails from a mbox file. # use: # - edit the mbox path below (default "/home/chad/Mailbox") # - run the script with no arguments # created: 2007-10-25 by chad clark # $Id$ use strict; use Email::Delete qw(delete_message); my @subject_list = ( '^DELIVERY FAILURE.*$' , '^Delivery Notification: Delivery has failed' , '^Delivery Status Notification.*$' , '^Mail delivery failed: returning message to sender' , '^Message you sent blocked by our bulk email filter' , '^Returned mail: see transcript for details' , '^Undeliverable:.*$' , '^Undelivered Mail Returned to Sender' , '^failure notice$' , ); { local $" = '|'; print "@subject_list" , "\n"; delete_message from => '/home/chad/Mailbox', matching => sub { my $message = shift; local $" = '|'; $message->header('Subject') =~ m/"@subject_list"/; }; }