有没有办法让PHP表单UTF-8友好而没有HTML-Email-Content?我当前的脚本不起作用。我认为"内容类型"标题中仅适用于HTML-Content,对吧?
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get the form fields and remove whitespace.
$anrede = $_POST['anrede'];
$vorname = $_POST['vorname'];
$nachname = $_POST['name'];
$email = $_POST['email'];
$nachricht = $_POST['nachricht'];
if ( empty($firma) OR empty($vorname) OR empty($nachname) OR empty($email) OR empty($nachricht) ) {
// Set a 400 (bad request) response code and exit.
header("HTTP/1.0 404 Not Found");
echo "Error!";
exit;
}
$recipient_edc = "my@email.de";
$subject = "edc-daten.de | $vorname $nachname";
$email_content = "Name: $anrede $vorname $nachname\n";
$email_content .= "E-Mail: $email\n\n";
$email_content .= "Nachricht:\n$nachricht\n";
$email_headers = "From: $vorname $nachname <$email>";
$email_headers .= "Content-type: text/plain; charset=UTF-8" . 'rn';
if (mail($recipient_edc, $subject, $email_content, $email_headers)) {
header("HTTP/1.1 200 Ok");
echo "Erfolg!";
} else {
header("HTTP/1.1 500 No Record Found");
echo "Error!";
}
} else {
header('HTTP/1.0 403 Forbidden');
echo "Error!";
}
?>