Page 1 of 1

UTF-8 program

Posted: Fri Nov 20, 2009 12:04 pm
by broch
I want to send a plain text email as UTF-8 encoded with Quotes Printables via the php mail() function, but there seems to be some discrepancies between php UTF-8 encoding and the encoding used by e.g Outlook express. The problem especially arise when I want to send the € sign (euro sign). Outlook express is creating =E2=82=AC as quoted-printable or € in plain ascii, but PHP will never output that.

When converting the € sign the output becomes € in plain ascii and outlook express won't accept that. The danish letters æ,ø,å works in this way, but not when sending the mail to a mac computer.

What I do is:

Code: Select all

function bs_mail($to_name, $to_email_address, $email_subject, $message, $from_email_name, $from_email_address) {
    $to      = $to_name.' <'.$to_email_address.'>';
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= 'Content-Type: text/plain; charset="utf-8"'."\r\n";
        $headers .= "Content-Transfer-Encoding: quoted-printable\r\n";
 
    $headers .= 'From: '.$from_email_name. ' <'.$from_email_address.'>'."\r\n" .
           'X-Mailer: '.BS_SHOPNAME;
 
 
    $message = mb_convert_encoding($message,"utf-8");
    $message = str_replace("€","€",$message);     //The php convert encoding for UTF-8 doesn't work with mails. This works better
    $message = mb_convert_encoding($message,"quoted-printable");
 
 
    mail($to, $email_subject, $message, $headers);
}
Why are there two representations of € in UTF-8? Or what do I do wrong?
Any ideas about this?

Best regards,
broch