Hello All,

I'm running Cyrus+Postfix+Amavisd-new (Spamassasin+ClamAV).

The problem is that non-encoded 8bit data is not allowed in message headers and 
Cyrus-IMAPd prevents from any problem by replacing those chars with X. 

A lot of emails my user get are coming from hotmail host with those XXX in 
subject header.

Hotmail web-interface is not a standards-compliant mail program that does not 
RFC 2047-encoding on all headers. Unencoded 8-bit characters aren't allowed in 
headers. That's why Cyrus replaces them with X.

I thought I could solve it on the amavis level.
As you can see below, amavis warns about "BAD HEADER"

> X-Amavis-Alert: BAD HEADER Non-encoded 8-bit data (char F7 hex) in 
> message header 'Subject'
>   Subject: \367\345\370\361 \344\351\351\362\345\365\n           ^

Is there a way to use function function encode($in_str, $charset) on Subject 
header when amavis see the "BAD HEADER" in Subject?

Where should I enter the encode code?



P.S.:
Below is function encode($in_str, $charset) code:

$charset = "ISO-8859-8";
function encode($in_str, $charset) { 
   $out_str = $in_str; 
   if ($out_str && $charset) { 

       // define start delimimter, end delimiter and spacer 
       $end = "?="; 
       $start = "=?" . $charset . "?B?"; 
       $spacer = $end . "\r\n " . $start; 

       // determine length of encoded text within chunks 
       // and ensure length is even 
       $length = 75 - strlen($start) - strlen($end); 
       $length = floor($length/2) * 2; 

       // encode the string and split it into chunks 
       // with spacers after each chunk 
       $out_str = base64_encode($out_str); 
       $out_str = chunk_split($out_str, $length, $spacer); 

       // remove trailing spacer and 
       // add start and end delimiters 
       $spacer = preg_quote($spacer); 
       $out_str = preg_replace("/" . $spacer . "$/", "", $out_str); 
       $out_str = $start . $out_str . $end; 
   } 
   return $out_str; 
}

$subject = encode(($in_str, $charset);



Best Regards,
Leon Kolchinsky


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/

Reply via email to