Reputation: 8727
I'm sending a PHP email using:
mail($email, $subject, $message, $header);
I layout the message like this which includes some tables with prices like this:
$message = <<<EOF
<td style=\"border-bottom: 1px solid black; padding-bottom:4px; padding-top:4px; padding-right: 10px; text-align:right;\">£</td>
EOF;
On certain email clients the £ appears as £.
I understand this is to do with character formatting. But how do set UTF-8 character set when sending a PHP email in this way?
TIA
Upvotes: 3
Views: 3642
Reputation: 17721
This is a more general solution than fin1te's:
$header = array(
"From: {$email}",
"MIME-Version: 1.0",
"Content-Type: text/html;charset=utf-8"
);
$result = mail($email, $subject, $message, implode("\r\n", $header));
Upvotes: 3
Reputation: 11062
Firstly, you could use
£
instead of the raw £
character.
To set character encoding of email, set up the headers:
$from = '[email protected]';
$to = '[email protected]';
$subject = 'Subject';
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$message = 'message';
mail($to, $subject, $message, $headers);
Upvotes: 3