Found this neat PHP function for sending UTF-8 encoded email. I made a little adjustment so that it’ll be able to send HTML formatted messages.
#– Start of Code
// Encoding of Message, From, Subject and To into UTF-8 format before sending
function UTF8_mail($from, $to, $subject, $message, $cc=”, $bcc=”)
{
$from = explode(“<”,$from );$headers = “From: =?UTF-8?B?” .base64_encode($from[0]).”?= <”. $from[1] . “\n”;
$to = explode(“<”,$to );
$to = “=?UTF-8?B?”.base64_encode($to[0]).”?= <”. $to[1] ;$subject=”=?UTF-8?B?”.base64_encode($subject).”?=\n”;
if($cc!=”)
{
$cc = explode(“<”,$cc );
$headers .= “Cc: =?UTF-8?B?”.base64_encode($cc[0]).”?= <”. $cc[1] . “\n”;
}if($bcc!=”)
{
$bcc = explode(“<”,$bcc );
$headers .= “Bcc: =?UTF-8?B?”.base64_encode($bcc[0]).”?= <”. $bcc[1] . “\n”;
}$headers .=
“Content-Type: text/html; “
. “charset=UTF-8; format=flowed\n”
. “MIME-Version: 1.0\n”
. “Content-Transfer-Encoding: 8bit\n”
. “X-Mailer: PHP\n”;return mail($to, $subject, $message, $headers);
}
#– End of Code
P.S. If you want to send just a simple text format mail, just replace “Content-Type: text/html; ” to “Content-Type: text/plain; “





