[imp] ISO encoding in 'To:' header
Sameh Ghane
sw@anthologeek.net
Fri Oct 18 19:47:45 2002
Hi,
Before I switch to IMP HEAD, here is a little problem I was recently confronted
to:
when headers contain 8bit characters, MS OExpress (and maybe others) encodes
them using the charset also specified in the headers of the mail.
Unfortunately, this leads to strange behaviours when sending and email to a such
an address:
To: Roméo Luigi <blah@foo.bar>
becomes:
To: =?iso-8859-1?Q?Rom=E9o_Luigi?= <blah@foo.bar>
Apparently, in RELENG_3, this kind of address is not handled correctly, as it
leads to this recipient: <@>.
I did not debug through the whole Horde/IMP, so I don't know whose fault it is,
but simplifying the recipients list in format_addresses() helped me get rid
of this bug (using sendmail, the mail was sent to root@, using SMTP, an error
(recipient <@> rejected) was sent to the IMP user).
Here is an ugly patch that should help people having the same problem.
Basically, instead of not trimming recipient lists including the '>' char, it
generates a clean list extracted from standard email addresses.
Caution: if the recipient does not match the regular expression, he will be
lost, for example, an alias without '@' will be dropped, same for an empty
domainname. It could be tweaked by changing the regexp.
Maybe the developpers could add a better patch to the tree ?
day$ cvs diff -bu compose.php
Index: compose.php
===================================================================
RCS file: /repository/imp/compose.php,v
retrieving revision 2.369.2.48
diff -b -u -r2.369.2.48 compose.php
--- compose.php 30 Sep 2002 18:21:33 -0000 2.369.2.48
+++ compose.php 18 Oct 2002 18:14:22 -0000
@@ -293,6 +293,14 @@
$address_string = trim(strtr($address_string, ';,', ' '));
$address_string = preg_replace('|\s+|', ', ', $address_string);
}
+ if (strpos($address_string, '>') && ($nb_matchs=preg_match_all("/[\w\-]+((\.|\+)[\w\-]+)*@[a-z0-9\-]+(\.[a-z0-9\-]+)+/i", $address_string, $match_array) ) ) {
+ $address_string = "";
+ for ($i=0; $i<$nb_matchs; $i++) {
+ $address_string .= $match_array[0][$i];
+ if ($i<$nb_matchs-1)
+ { $address_string .= ", "; }
+ }
+ }
return $address_string;
}
Hope this helps someone,
Regards,
--
Sameh