Reputation: 159
<?php
$email = $_POST["email"];
$from = "From: $email \n";
$from .= "Content-type: text/html; charset=UTF-8;";
$to = "[email protected]";
$title = $_POST["typ"] . " - " . $_POST["name"];
$title = "=?UTF-8?B?" . base64_encode($title) . "?=";
$tel = "";
$tel = $_POST["tel"];
if(empty($tel)) {
$tel = "";
}
else {
$tel = "Telefon - " . $tel . '<br/>';
}
$text = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body>';
$text .= $_POST["text"];
$text .= "<br/><br/>".$tel;
$text .= "</body></html>";
mail($to, $title, $text, $from);?>
I added charset=utf-8. My code editor coding is set to utf-8. My title has special characters but the email body doesn't have them. Please help me!
After changes (it works):
<?php
$email = $_POST["email"];
$from = "MIME-Version: 1.0" . "\r\n";
$from .= "Content-Type: text/html; charset=utf-8\r\nContent-Transfer-Encoding: base64\r\n";
$from .= "From: $email" . "\r\n";
$to = "[email protected]";
$title = $_POST["typ"] . " - " . $_POST["name"];
$title = "=?UTF-8?B?" . base64_encode($title) . "?=";
$tel = "";
$tel = $_POST["tel"];
if(empty($tel)) {
$tel = "";
}
else {
$tel = "Telefon - " . $tel . '<br/>';
}
$text = '<html><head><meta charset="utf-8"></head><body>';
$text .= $_POST["text"];
$text .= "<br/><br/>".$tel;
$text .= "</body></html>";
$text = base64_encode($text);
echo $text;
mail($to, $title, $text, $from);?>
Upvotes: 0
Views: 1672
Reputation: 6758
As noted by Deadooshka in its comment, you have to change the line
$from .= "Content-type: text/html; charset=UTF-8;";
to
$from .= "Content-Type: text/html; charset=utf-8\r\nContent-Transfer-Encoding: base64\r\n";
Upvotes: 1