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.=20
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=20
> 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 =3D "ISO-8859-8";
function encode($in_str, $charset) {=20
$out_str =3D $in_str;=20
if ($out_str && $charset) {=20
// define start delimimter, end delimiter and spacer=20
$end =3D "?=3D";=20
$start =3D "=3D?" . $charset . "?B?";=20
$spacer =3D $end . "\r\n " . $start;=20
// determine length of encoded text within chunks=20
// and ensure length is even=20
$length =3D 75 - strlen($start) - strlen($end);=20
$length =3D floor($length/2) * 2;=20
// encode the string and split it into chunks=20
// with spacers after each chunk=20
$out_str =3D base64_encode($out_str);=20
$out_str =3D chunk_split($out_str, $length, $spacer);=20
// remove trailing spacer and=20
// add start and end delimiters=20
$spacer =3D preg_quote($spacer);=20
$out_str =3D preg_replace("/" . $spacer . "$/", "", $out_str);=20
$out_str =3D $start . $out_str . $end;=20
}=20
return $out_str;=20
}
$subject =3D 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_id=7637&alloc_id=16865&op=click
_______________________________________________
AMaViS-user mailing list
AMaVi...@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/
> 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.
> [...] Is there a way to use function function encode($in_str, $charset)
> on Subject header when amavis see the "BAD HEADER" in Subject?
Whou would you know to what character set the raw bytes in Subject belong?
Could be UTF-8, or one of the Latin character sets, or anything else.
This information was only known to the sender, and then lost.
Mark
I don't really care if Subjects BAD HEADER for "Latin" or another =
encoding would be scrambled (if it is already "BAD").
I really want only this $charset =3D "ISO-8859-8"; - Hebrew
particular charset to be "GOOD" in case it's not encoded.
So, I prefer to encode all Subjects "BAD HEADERS" with the encode =
function.
Best Regards,
Leon Kolchinsky
-----Original Message-----
From: amavis-u...@lists.sourceforge.net =
[mailto:amavis-u...@lists.sourceforge.net] On Behalf Of Mark =
Martinec
Sent: Tuesday, January 03, 2006 3:29 PM
To: amavi...@lists.sourceforge.net
Subject: Re: [AMaViS-user] How to Encode - BAD HEADER Non-encoded 8-bit =
data
Leon,
> 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.
> [...] Is there a way to use function function encode($in_str, =
$charset)
> on Subject header when amavis see the "BAD HEADER" in Subject?
Whou would you know to what character set the raw bytes in Subject =
belong?
Could be UTF-8, or one of the Latin character sets, or anything else.
This information was only known to the sender, and then lost.
Mark
-------------------------------------------------------
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_id=3D7637&alloc_id=3D16865&op=3Dclick