hMailServer External Copies

This is an old script, don’t plan to update/support it. I’m leaving it here for reference only!

I was recently asked by a friend to help setup a small mail server at his office. I found the hMailServer the best free option for small business. I would personally recommend anyone looking for a simple powerful (not to mention free) mailserver to try this one. I setup a global catch all account on the hosting provider (GoDaddy) and using the external account feature to download and distribute locally. So, we setup the server and all was well.

The very next day the guy called me and said although everything works fine, they are getting multiple copies of same mail. Further investigation revealed that everytime someone mailed 2 of more people in the same company, they all get multiple copies (depending on how many people were in the TO: CC: BCC:). Initially I couldn’t figure out what was causing this to happen. Later it was clear, everytime someone sends a mail to multiple people the external account (with catch all enabled) receives a copy for each mail address. When hMailServer download from this account it gets multiple mails and it forwards each one to the recipients. This is not a problem with hMailServer but it does bother everyone.

Finally I came up with a solution and so far it seems to work fine. I wrote a small script that computes a hash of every incoming mail and checks if it is an exact copy. The subject line of copies are marked allowing them to be deleted.

The script could be found here or here.

This is to be placed in the hMailServer\Events folder. If you have other scripts in the existing file you’ll need  to copy and paste the script manually. Now to delete copies just add a global rule that deletes all mails with -~!GLOBAL MAILBOX COPY!~- in subject line.

Hope this works for you!