note 107897 added to function.iconv-mime-encode
| From: | cedric at gn dot apc dot org | Date: | Tue, 13 Mar 2012 15:54:14 +0000 |
| Subject: | note 107897 added to function.iconv-mime-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186638@lists.php.net to get a copy of this message | ||
iconv_mime_encode() isn't directly suitable for encoding headers which include
"specials" as described in RFC 1522 s4 & s5, for example
<?php
$mimeprefs = array ("scheme" => "Q",
"input-charset" => "utf-8",
"output-charset" => "utf-8",
"line-break-chars" => "\n");
$enc = iconv_mime_encode('From', '"Réal Namé"
<user@example.com>', $prefs);
?>
will wrongly attempt to encode the angle brackets. To use the function in place of
mb_encode_mimeheader(), instead you need to encode the words separately, removing the superfluous
field name:
<?php
$encoded = "From: \"". preg_replace('/^:\s+/', '',
iconv_mime_encode("", $real, $mimeprefs))."\" <$email>";
?>
Also, values of "line-length" greater than 76 would be illegal under RFC 1522 and
resulting encoded words may not be recognised. (Not tested, but 72 would be safer.)
----
Server IP: 69.147.83.197
Probable Submitter: 93.96.136.249
----
Manual Page -- http://www.php.net/manual/en/function.iconv-mime-encode.php
Edit -- https://master.php.net/note/edit/107897
Del: integrated -- https://master.php.net/note/delete/107897/integrated
Del: useless -- https://master.php.net/note/delete/107897/useless
Del: bad code -- https://master.php.net/note/delete/107897/bad+code
Del: spam -- https://master.php.net/note/delete/107897/spam
Del: non-english -- https://master.php.net/note/delete/107897/non-english
Del: in docs -- https://master.php.net/note/delete/107897/in+docs
Del: other reasons-- https://master.php.net/note/delete/107897
Reject -- https://master.php.net/note/reject/107897
Search -- https://master.php.net/manage/user-notes.php