note 27698 deleted from function.mail by sniper
| From: | sniper@php.net | Date: | Wed, 29 Jan 2003 12:43:16 +0000 |
| Subject: | note 27698 deleted from function.mail by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-43064@lists.php.net to get a copy of this message | ||
Have you ever tried to send an email with a certain encoding (like ISO-8859-1) and found out that
the email works fine (you specified the encoding in the headers), but you cannot use those special
characters in the subject of the email?
This function encodes subjects so it works with encodings:
function EncodeEmailSubject($subject,$encoding="iso-8859-1")
{
$len = strlen($subject);
$enc = "=?".$encoding."?Q?";
for ( $i=0 ; $i<$len ; $i++ )
{
$c = ord(substr($subject,$i,1));
if ($c==32)
$c = ord('_');
$enc .= $c<128 ? chr($c) : sprintf("=%2X",$c);
}
return $enc . "?=";
}