Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail subject and Foreign Characters

Status
Not open for further replies.

RobHudson

Programmer
Apr 30, 2001
172
GB
Hi

I am having trouble dealing with foreign characters (non English) in the subject of an email generated using the mail() function.

An example subject: André is here

I have been trying to use this site ( for more info on how to do it and have been semi successful :)

This is the cunning bit...
When the email is received by Outlook 2003/2007 the accented character is replaced with X (AndrX is here). Yet when it received by a Hotmail or Yahoo account, it is displayed correctly.

Has anybody else had this problem or any ideas why it is happening?

Cheers
Rob

Code:
$subject1 = str_replace("é", "=?UTF-8?Q?=E9?=", $subject);

$headers = "From: ".$addr_from."\r\n";
$headers .= "Subject: ".$subject1."\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf8\r\n";

return mail($to,$subject,$html,$headers);
 
i don't think that the content type impacts the subject. i have, in the past, just included the roman characters in the subject string and they have been received by outlook clients without being mangled. when i have tried to do character translation, utf etc etc, it has never worked.

so... just try sending them through as they are. providing the user is using outlook's default font or another font with roman accented characters then all should be well.

i don't think the above holds true for multi-byte characters.
 
Thanks jpadie :)

If I don't encode the character the letter is still being shown as X in Outlook and Yahoo/Hotmail do not show it at all. This appears to be nearly the opposite of what you have :S

Outlook is using the default font.

I am using UTF8 as the content type because the body may contain multi-byte characters. Everything in the body is fine - it is only the subject that is messed up.
 
how curious. I'll investigate on other platforms.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top