2014-03-27 128 views
0

我有一个表单数据发送到电子邮件的大问题。当我填写我的订单,在电子邮件,我得到:从UTF-8发送表单数据到电子邮件

VÄrdiņš:LA«VA,

代替Vārdiņš:利华

我想我已经定好了UTF- 8,但没有任何变化。谁能帮忙?

这里是我的orders.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 = '[email protected]'; 

//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> 
+0

考虑使用这个类https://github.com/PHPMailer/PHPMailer发送相当好的邮件 –

回答

0

试试这个:

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

不,这个没有帮助:( – simonapruse

0

您可以添加标题

“Content-Type:text/html;字符集= UTF-8"

你的邮件正文。

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

如果您使用本地邮件()函数$头阵列将是第四个参数邮件($到,$主题,$消息,$ headers)

+0

当我添加它,我没有收到电子邮件 – simonapruse

+0

您的电子邮件服务是否正常工作?您检查了吗? –

相关问题