Sieve Filter to Block Messages in Unwanted Character sets

Document ID: 10432

Synopsis

In some instances you may wish to block all e-mails that are written in a particular character set.

More Information

Sieve Filter to Block Messages in Unwanted Character sets

In some instances you may wish to block all e-mails that are written in a particular character set.

Setup

Before undertaking the steps listed below please ensure that you have completed all actions within this KB 10419 to use the below Sieve filters.

This sieve filter will work on all received messages as long as you have 'scan all messages received by SMTP' set within your Anti Spam settings and have the filter within your Server Receive Scripts.

Should you wish to test these filter against outgoing messages then you will need to place the filter in either the domain, forced mailbox or mailbox level sieve filters.

Add the following sieve filters into the filter level depending on whether it is for incoming or outgoing messages.

  • Server > Filtering > Sieve Filter > Server Receive Script/ Mailbox Sieve Script etc > Edit > Advanced
  • Just under the 'require' statement at the top paste the below sieve filters into this location

/*
RuleName: Add Character Set to header
RuleDescription: Adds spam score to message X-Header
*/
if true {
            /*This command is inserted to make the $spamscore variable available.*/
            if spamtest :matches :comparator "i;ascii-numeric" "*" {set "spamscore" "$1";}
                addheader"X-Spam-Score-Charsets" "$spamtest.charsets";
}
 

/*
RuleName: Reject Cyrillic
RuleDescription:
*/
if header :regex "X-Spam-Score-Charsets" "(koi8-r|windows-1251|x-mac-cyrillic|koi8|iso-8859-5)" {
    reject "Message rejected by content filter.";
    stop;
}

  • Click OK
  • If you get an error you may need to add "regex" to the 'Require' statement at the top of this screen
  • Finally stop and restart the SMTPRA and SMTPDA services to complete this change
To add more CharSets please visit this website for a full listing http://www.w3.org/International/O-charset-list.html