Removing Duplicate E-mail Messages From A Mailbox

Linux, SysAdmin, Technical
Occasionally your mail delivery scheme might hiccup, leaving you with duplicate copies of email messages sitting in your mailboxes. I find this happens occasionally if something goes wrong with fetchmail - you kill the fetchmail process before it has expunged the deleted email from the remote POP3 server, so the next time you run fetchmail it downloads a second copy of each email. This is a simple process that I came up with to remove duplicate email messages from a maildir format mailbox. As a bit of background, a maildir mailbox is a small directory tree: $ du .boxes.xml-dev 4 .boxes.xml-dev/tmp 124 .boxes.xml-dev/new 52340 .boxes.xml-dev/cur 52920 .boxes.xml-dev $ Hierarchy is represented by components of the mailbox name separated by dots, so the mailbox above is called xml-dev and it is in the boxes mailbox. Messages are files in…
Read More