将Unicode UTF8添加到电子邮件中

Can anyone help me please how to add a utf-8 Unicode for these characters?

žýáťčšľľzŽŘ

Now the email looks like this

Dostali ste novú správu. Tu sú podrobnosti: Jméno: tár Tel.Äíslo: 4996611

<?php

$EmailFrom = "...";
$EmailTo = "mail@mail";
$Subject = "Zpráva s ";
$name = Trim(stripslashes($_POST['name'])); 
$phone = Trim(stripslashes($_POST['phone'])); 
$email = Trim(stripslashes($_POST['email'])); 
$message = Trim(stripslashes($_POST['message'])); 

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "
";
$Body .= "Tel: ";
$Body .= $phone;
$Body .= "
";
$Body .= "Email: ";
$Body .= $email;
$Body .= "
";
$Body .= "Message: ";
$Body .= $message;
$Body .= "
";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

Thanks

You've got two ambiguous parts of your script where character-sets aren't being considered. It's possible your form isn't sending UTF-8 or it's possible you're sending UTF-8 in your email but the client is expecting a different encoding.

  1. I assume you're using a form to post data. Ensure it's set to send UTF-8 from the browser. The strings will now be UTF-8 encoded.

    <form action="myform" accept-charset="UTF-8">
    
  2. You need to add character set and transfer encoding headers to the email header:

    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit");
    

BTW, a faster way to redirect the user is to set the Location header in the response. Use:

header('Location: contactthanks.php')