Reputation: 10068
i need to send php email with html and special characters like è, à, ò .." and i've write this:
$message = "
<html>
<head>
<title>TITLE</title>
</head>
<body>
à è
</body>
</html>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'From: NoReply <[email protected]>' . "\r\n";
$headers .= "Reply-To: NoReply <[email protected]>\r\n";
mail($email, $subject, $message, $headers);
Now, when i launch my script, on gmail preview of received email is correct (letters are showed correctly), but when i open email, i see " à è", not the relative special character. How can i solve it (without using external libraries)?
Upvotes: 0
Views: 1169
Reputation: 2809
Use utf8_decode() function for $message.
$message = "<html>
<head>
<title>TITLE</title>
</head>
<body>
à è
</body>
</html>";
mail($email, $subject, utf8_decode($message), $headers);
Upvotes: 2
Reputation: 3147
In order to use special characters in your script you can try htmlspecialchars function.
Upvotes: 0