Reputation: 9552
I am sending an HTML email that contains an ü-Umlaut in it's body. I'm setting the encoding to UTF-8 in the HTML <head>
, as well as in the mail header:
HTML
$body = '<html>
<head>
<title>My Title</title>
<meta charset="utf-8">
</head>
<body>
<h1>Here comes the ü-Umlaut</h1>
...
<p>Here comes an ö-Umlaut</p>
</body>
</html>';
Mail header
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=utf-8' . "\r\n";
When viewing the email on my iPhone, I see a ü
instead of the ü
. But when viewing the mail on my gmail account, the ü
is displayed correctly. The ö
is displayed correctly on both devices.
A colleague of mine correctly views the ü
in his email client. But he doesn't see the ö
, but a square with a question mark inside (probably something like �
).
Now what's gone wrong here and how can I fix it?
Upvotes: 0
Views: 2200
Reputation: 451
Make sure your php file also forces UTF-8:
<?php
header('Content-type: text/html; charset=UTF-8');
same counts for the calling html page:
<meta http-equiv="content-type" content="text/html; charset=utf-8">
or if you use ajax:
$.ajax(
{
url: './sendemail.php',
type: 'POST',
contentType: "application/x-www-form-urlencoded; utf-8",
All participants must use the same charset. Especially the final email client:
<meta http-equiv=Content-Type content=text/html; charset=UTF-8>
Upvotes: 1