note 27698 added to function.mail

From: Date: Mon, 16 Dec 2002 12:47:25 +0000
Subject: note 27698 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-40956@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 . "?="; } -- http://www.php.net/manual/en/function.mail.php http://master.php.net/manage/user-notes.php?action=edit+27698 http://master.php.net/manage/user-notes.php?action=delete+27698 http://master.php.net/manage/user-notes.php?action=reject+27698

« previous php.notes (#40956) next »