note 27998 added to function.mb-send-mail

From: Date: Sun, 29 Dec 2002 00:07:38 +0000
Subject: note 27998 added to function.mb-send-mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-41404@lists.php.net to get a copy of this message
If your server doesn't have mb_send_mail() enabled but you want to use non-ascii (multi-byte) chars in an email's subject or name headers, you can use something like the following: $charset = "iso-2202-jp"; // japanese $to = encode("japanese name 01", $charset) . " <to@email.com>"; $from = encode("japanese name 02", $charset) . " <from@email.com>"; $subject = encode("japanese text", $charset); $message = "does not need to be encoded"; mail($to, $subject, $message, $from); function encode($in_str, $charset) { $out_str = $in_str; if ($out_str && $charset) { // define start delimimter, end delimiter and spacer $end = "?="; $start = "=?" . $charset . "?B?"; $spacer = $end . "\r\n " . $start; // determine length of encoded text within chunks // and ensure length is even $length = 75 - strlen($start) - strlen($end); $length = floor($length/2) * 2; // encode the string and split it into chunks // with spacers after each chunk $out_str = base64_encode($out_str); $out_str = chunk_split($out_str, $length, $spacer); // remove trailing spacer and // add start and end delimiters $spacer = preg_quote($spacer); $out_str = preg_replace("/" . $spacer . "$/", "", $out_str); $out_str = $start . $out_str . $end; } return $out_str; } // for details on Message Header Extensions // for Non-ASCII Text see ... // http://www.faqs.org/rfcs/rfc2047.html -- http://www.php.net/manual/en/function.mb-send-mail.php http://master.php.net/manage/user-notes.php?action=edit+27998 http://master.php.net/manage/user-notes.php?action=delete+27998 http://master.php.net/manage/user-notes.php?action=reject+27998

« previous php.notes (#41404) next »