note 29038 added to ref.mail

From: Date: Fri, 31 Jan 2003 01:46:34 +0000
Subject: note 29038 added to ref.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-43167@lists.php.net to get a copy of this message
***Encoding plain text as quoted-printable in MIME email*** If you don't want to install IMAP and use imap_8bit() to encode plain text or html message as quoted-printable (friendly french special characters encoding :-) in MIME email, try this function. I haven't fully tested it ( like with microtime with long mails). I send html message as 7-bit, so I didn't try yet with html. If you have good html practise, you don't really need to encode html as quote-printable as it only uses 7-bit chars. F.Touchard function qp_encoding($Message) { /* Build (most polpular) Extended ASCII Char/Hex MAP (characters >127 & <255) */ for ($i=0; $i<127; $i++) { $CharList[$i] = "/".chr($i+128)."/"; $HexList[$i] = "=".strtoupper(bin2hex(chr($i+128))); } /* Encode equal sign & 8-bit characters as equal signs followed by their hexadecimal values */ $Message = str_replace("=", "=3D", $Message); $Message = preg_replace($CharList, $HexList, $Message); /* Lines longer than 76 characters (size limit for quoted-printable Content-Transfer-Encoding) will be cut after character 75 and an equals sign is appended to these lines. */ $MessageLines = split("\n", $Message); $Message_qp = ""; while(list(, $Line) = each($MessageLines)) { if (strlen($Line) > 75) { $Pointer = 0; while ($Pointer <= strlen($Line)) { $Offset = 0; if (preg_match("/^=(3D|([8-9A-F]{1}[0-9A-F]{1}))$/", substr($Line, ($Pointer+73), 3))) $Offset=-2; if (preg_match("/^=(3D|([8-9A-F]{1}[0-9A-F]{1}))$/", substr($Line, ($Pointer+74), 3))) $Offset=-1; $Message_qp.= substr($Line, $Pointer, (75+$Offset))."=\n"; if ((strlen($Line) - ($Pointer+75)) <= 75) { $Message_qp.= substr($Line, ($Pointer+75+$Offset))."\n"; break 1; } $Pointer+= 75+$Offset; } } else { $Message_qp.= $Line."\n"; } } return $Message_qp; } -- http://www.php.net/manual/en/ref.mail.php http://master.php.net/manage/user-notes.php?action=edit+29038 http://master.php.net/manage/user-notes.php?action=delete+29038 http://master.php.net/manage/user-notes.php?action=reject+29038

« previous php.notes (#43167) next »