Uli
Uli

Reputation: 2693

PHP - Special characters

I'm trying to send these characters through PHP:

áéíóúüchlñÁÉÍÓÚÜCLÑ

They show up in the received email like this:

áéÃóúüchlñÃÃÃÃÃ

I tried htmlentities but without success:

$newsubject = htmlentities($subject, ENT_COMPAT, "UTF-8");
mail($notes,$newsubject,$message,$headers);

Does anybody have an idea what I could try? Thanks

Upvotes: 0

Views: 1034

Answers (3)

Korhan Ozturk
Korhan Ozturk

Reputation: 11308

I think, you need to use MIME (Multipurpose Internet Mail Extensions).

Add your mail headers the following:

MIME-Version: 1.0
Content-Type: text/plain;charset=utf-8

Upvotes: 2

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324610

You are attempting to send them as UTF-8 but your PHP is handling them as latin-1.

Call utf8_encode on the input string to treat it as UTF-8 again.

EDIT: Misread the question. Add a header to the email you're sending:
Content-Type: text/plain; charset=utf-8

Upvotes: 0

Matt Lo
Matt Lo

Reputation: 5731

Your character set is wrong on the characters themselves. Try this: (Windows) Copy and paste those characters from a "UTF-8 character set" site back into your application. Make sure your doucument is UTF-8, and BOM Signature disabled.

Upvotes: 0

Related Questions