Delete Duplicate Email messages from Server

I am sure a lot of us have faced this problem of receiving multiple email copies specially when the addresses are forwarded.

I had a setup where, and were forwarded to . Any email addressed to all 4, used to end up 4 times in collect box. This was an archieval box so multiple copies not only wasted the server space and resources but also made it difficult to search a particular message.

I was looking for a script that could run on the server and delete teh mails from the server itself, without me having to downlaod them first to the PC. There are plugins for Thunderbird that would let you delete the duplicate messages once you have downloaded them , but I wanted an on the server solution

The solution came from a script written by Quentin It’s a python script and it marks all the duplicate messages as Deleted on the email server itself.

from command line you can run it simply by specifying your mail server, user id , password and mailbox name . You can also run it with -v to see what goes on.

path_to_imapdedup/ -s -u myuserid -w secretpassword -n MAILBOXNAME

This is an excellent solution for anyone looking to delete large number of duplicate emails straight from the server without having to download the message first.