[Mimedefang] Q about Rejecting based on charset

Dirk the Daring dirk at psicorps.org
Fri Jun 24 12:25:13 EDT 2005


   I've noticed that a lot of the SPAM that I get uses oddball character
sets, while most of my HAM is either US-ASCII or UTF-8. Examining the
SPAM a bit more, I've compiled a list of about 8 character sets that are
apparently always SPAM.

   I found some sample filter code on a website, and I'm trying to adapt
it to what I want to do, which is reject E-Mail using these character
sets. I'd appreciate a sanity-check of both the code and the idea.

   This is what I'm adding to "sub filter":

   $head = $entity->head;
   $charset = $head->mime_attr("content-type.charset");
   if (defined($charset)) {
     $charset =~ tr/A-Z/a-z/;
     if ($charset eq "ks_c_5601-1987" or
         $charset eq "euc-kr" or
         $charset eq "iso-2022-kr" or
         $charset eq "big5" or
         $charset eq "windows-1251" or
         $charset eq "windows-1255" or
         $charset eq "gb2312" or
         $charset eq "gb2312_charset") {
         syslog('alert',"MIMEDefang rejected an E-Mail using charset $charset");
         return ('REJECT', "CONTENT VIOLATION: Mail using character set $charset not accepted here");
     else {
         return action_accept();
     }
   }

   Thanks for help and advice.

Dirk



More information about the MIMEDefang mailing list