为什么不能用php代码发送utf-8邮件?

时间:2017-05-16 10:44:36

标签: php forms utf-8

我有一个html表单,我不能用UTF-8中的php代码发送。当电子邮件到达时,“ÁŰÚÓÖŐ”字符是:“????”我尝试了很多机会,但我没有成功。谢谢你的帮助

这是我的代码:

    <?php

if(!isset($_POST['submit']))
{
    echo "error; you need to submit the form!";
}
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

if(empty($name)||empty($email))
{
    echo "Name and email are mandatory'";
    exit;
}

$email_from = "myemail@myemail.com";
$email_subject = "Megrendeles";
$email_body = "Új üzenet $name rendelőtől.\n".
    "email címe: $email\n".
    "Leírás:\n $message".

$to = "myemail@myemail.com";
$headers = "From: $email_from \r\n";
$headers .= "Content-Type: text/plain; charset=UTF-8\r\n";
$headers .= "Content-Transfer-Encoding: UTF-8\r\n";
$headers .= "MIME-Version: 1.0";

mail($to,utf8_decode($email_subject),utf8_decode($email_body),utf8_decode($headers));

0 个答案:

没有答案