Pegasus Mail & Mercury

Welcome to the Community for Pegasus Mail and
The Mercury Mail Transport System, the Internet's longest-serving PC e-mail system!
Welcome to Pegasus Mail & Mercury Sign in | Join | Help
Home Blogs Forums Downloads Pegasus Mail Overview Mercury Overview Wiki

Mail filtering add on

Last post 09-14-2018, 3:20 by Brian Fluet. 2 replies.
Sort Posts: Previous Next
  •  09-13-2018, 12:26

    • Tym is not online. Last active: 17 Sep 2018, 17:24 Tym
    • Not Ranked
    • Joined on 09-13-2018
    • Preston, UK
    • Member
    • Points 50

    Mail filtering add on

    Hi peeps,

     After a long time of using an Excuse of a mail server, I've reverted to Mercury, and it feels good to be back! Running 4.80 as a service (bought license)...

    The only "problem" I have, like most people I suppose, is that of spam.  I've got Spamhalter ticked, configured MercuryS to use Spamhaus, abuseat, spamcop etc and also added transaction filters for certain words in the MercuryS exceptions.

    It's probably me not setting things up correctly, but these don't seem to cut the mustard.

    So... I've written a little program that does what I need and it is triggered as a Policy on each mail that comes in.

     We have a filter.rules file which specifies words to test each line for and the weight achieved when *all* are matched. For example, this is a simple rules file:

    #weight, list of words separated by commas



     *All* of the words have to appear for the weighting to be applied, so if "flight" and "simulator" are in the body, and not the subject, this won't trigger. Similarly if it is sent from the weighting is reduced so the rule doesn't trigger

    This program allows other lines within the email text to be tested not just the ones provided for in the transaction filter.

    It is used like this:

    Create a new policy

     Type of task is "Run a program and examine the return code"

    Command line is

    mercuryfilter ~A TotalWeight AppendLog

      for example:

    mercuryfilter ~A 100 true

    This will  cause the program to trigger a policy failure if the total weighting of the all the rule triggers is equal to or greater than 100. It also creates a log file which can either be replaced by each new email or appended by each one. If you want to keep a log of all the emails passed through, set the AppendLog flag to true. There's a different log file for each day.

    I also have step 4 set to forward the emails that fail to me, just so I can check... 

     If you want to have a try, it can be downloaded at

     Use with caution - no warranty is provided or implied! :-) It seems to do what I need it to here...

     The program installs to the c:\mercury by default and needs DotNet 4.5.2 to be installed.

     Hopefully I've not reinvented the wheel, but I'd appreciate any comments - especially if it's useful to someone else!




    Filed under: ,
  •  09-13-2018, 20:12

    • PaulW is not online. Last active: 14 Sep 2018, 9:56 PaulW
    • Top 10 Contributor
    • Joined on 05-08-2007
    • UK
    • SuperStar
    • Points 18,150

    Re: Mail filtering add on

    Interesting, and thanks for sharing it.

    They always say that no two folks' spam is the same and I find that not much gets through my Mercury with a similar setup.  The main difference is that I use Clamwall with extra signatures from, and that leaves little for a well-trained Spamhalter to do.

    It's useful to have a log and the ability to forward spam mails as you do - just in case of false positives. 

  •  09-14-2018, 3:20

    • Brian Fluet is not online. Last active: 09-22-2018, 21:03 Brian Fluet
    • Top 10 Contributor
    • Joined on 12-24-2014
    • North Carolina, USA
    • SuperStar
    • Points 21,845

    Re: Mail filtering add on

    I'm use Clamwall with extra SaneSecurity signatures as well in conjunction with POPFile instead of Spamhalter.

    All spam tagged messages are filtered to a Spam mailbox for review.  The rare false positives get fowarded to the appropriate user from there.

View as RSS news feed in XML

Contact | Advertise | Host provider: PraktIT | Terms of Use | Privacy Statement
Copyright © 2007-2011 David Harris / Peter Strömblad. | Pegasus Mail Home Page