utf -8 -发送表单数据从php页面到电子邮件在utf -8


utf 8 - Sending form data from php page to email in UTF-8

我有一个表单数据发送到电子邮件的大问题。当我填写订单时,在电子邮件中我收到:

VÄrdiņŠ': LÄ«va,

代替Vārdiņš: Līva

我想我已经正确设置了utf-8,但是没有任何变化。有人能帮忙吗?

这是我的订单。php

    <?php
header('Content-Type: text/html; charset=utf-8');
mb_internal_encoding( 'UTF-8' );
//subject and email variables//
$emailSubject = 'Pasūtījums no www.gramatina.lv';
$webMaster = 'info@gramatina.lv';
//gathering data variables//
$type = $_POST['type'];
$typography = $_POST['typography'];
$spiral = $_POST['spiral'];
$color_name = $_POST['color_name'];
$nameYes = $_POST['nameYes'];
$unryu = $_POST['unryu'];
$nameU = $_POST['nameU'];
$shipping = $_POST['shipping'];
$totalPrice = $_POST['totalPrice'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$address = $_POST['address'];
$comments = $_POST['comments'];
$other_color = $_POST['other_color'];
$body = <<<EOD
Grāmatas veids: $type
Krāsa: $typography, $spiral, $unryu, $other_color
Ar vai bez vārdiņa: $color_name
Vārdiņš: $nameYes, $nameU
Piegādes veids: $shipping
Cena: $totalPrice
Vārds, uzvārds: $first_name, $last_name
E-pasta adrese: $email
Telefona numurs: $telephone
Piegādes adrese: $address
Komentārs: $comments
EOD;
$header = "From: $email";
If($_POST){
    mail($webMaster, $emailSubject, $body, $header);
    header('Location: thank_you_order.html');
}
?>

这里是html页面标题:

        <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>Mūsu mazuļa grāmatiņa</title>
    </head>
    <body>
        <div id="form">
            <form action="orders.php" method="post">
        </div>
    </body>
    </html>

试试这个:

mail($webMaster,'=?UTF-8?B?'.base64_encode($emailSubject).'?=', $body, $header_ . $header);

可以添加标题

" content - type: text/html;utf - 8字符集= "

到你的消息正文。

$headers = array("Content-Type: text/html; charset=UTF-8");

如果你使用本机mail()函数$headers数组将是第四个参数mail($to, $subject, $message, $headers)