drhanjuw56233 2015-07-10 07:34
浏览 187

从表单发送的电子邮件中显示的输出不会以泰语显示

I really need help with getting my form to email the output in Thai language. I've been trying to fix it but I think that I don't have enough knowledge or understanding on this so it's time I seeked help.

I checked phpMyAdmin, the settings are like this..

Server charset: UTF-8 Unicode (utf8) 
Server connection collation: utf8_unicode_ci

My form is (briefly) like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Tell A Friend</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form id="Tell A Friend" name="Tell A Friend" method="post" action="tellafriend.php">
<table width="520" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="250" align="right">ชื่อผู้เสนอเพื่อน :</td>
<td width="258"><label for="name"></label>
  <span id="sprytextfield1">
  <label for="name2"></label>
  <input type="text" name="name" id="name2" />
  <span class="textfieldRequiredMsg">กรุณากรอก</span></span></td>
</tr>
<tr>
<td align="right">อีเมลล์ของผู้เสนอเพื่อน :</td>
<td><label for="email"></label>
  <span id="sprytextfield2">
  <label for="email2"></label>
  <input type="text" name="email" id="email2" />
  <span class="textfieldRequiredMsg">กรุณากรอก</span></span></td>
</tr>
<tr>
<td align="right">เบอร์โทรศัพท์ของผู้เสนอเพื่อน :</td>
<td><label for="phone"></label>
  <span id="sprytextfield3">
  <label for="phone2"></label>
  <input type="text" name="phone" id="phone2" />
  <span class="textfieldRequiredMsg">กรุณากรอก</span></span></td>
</tr>
<tr>
<td align="right">ชื่อเพื่อนที่ต้องการแนะนำ :</td>
<td><label for="friendsname"></label>
  <span id="sprytextfield4">
  <label for="friendsname2"></label>
  <input type="text" name="friendsname" id="friendsname2" />
  <span class="textfieldRequiredMsg">กรุณากรอก</span></span></td>
</tr>
<tr>
<td align="right">อีเมลล์ของเพื่อนที่ต้องการแนะนำ :</td>
<td><label for="friendsemail"></label>
  <span id="sprytextfield5">
  <label for="friendsemail2"></label>
  <input type="text" name="friendsemail" id="friendsemail2" />
  <span class="textfieldRequiredMsg">กรุณากรอก</span></span></td>
</tr>
<tr>
<td align="right">เบอร์โทรศัพท์ของเพื่อนที่ต้องการแนะนำ :</td>
<td><label for="friendsphone"></label>
  <span id="sprytextfield6">
  <label for="friendsphone2"></label>
  <input type="text" name="friendsphone" id="friendsphone2" />
  <span class="textfieldRequiredMsg">กรุณากรอก</span></span></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr>
</table>
      </form>
</body>
</html>

Here's my PHP:

<?php
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$autoreply="Dear $name,

Thank you for visiting the Thai Au Pair website and for telling your friend about us!

We hope you and your friend do not let this great opportunity of being an Au pair 
abroad pass you by!

Thanks again and we look forward to welcoming you both to our office!

Thai Au Pair Team

สวัสดีค่ะ

ขอบคุณที่ได้เยี่ยมชมเว็บไซด์ไทยออแพร์ของเรา และยังได้แนะนำเพื่อนๆ ที่อาจจะสนใจโครงการออแพร์ของเราอีกด้วยนะคะ

ทางทีมงานหวังเป็นอย่างยิ่งว่าคุณและเพื่อนจะได้มีโอกาสเป็นหนึ่งในสมาชิกของโครงการ ในขณะที่ยังสามารถเข้าร่วมได้อยู่ อย่าปล่อยให้เวลาผ่านไปนะคะ และขอขอบพระคุณอีกครั้งสำหรับความสนใจ โดยทีมงานหวังว่าจะได้มีโอกาสได้ต้อนรับคุณและเพื่อนที่ออฟฟิศไทยออแพร์ในเร็วๆ นี้นะคะ";
$subject="Thaiaupair.com-Thank you for your submission.";
mail($email, $subject, $autoreply);

$friendsname=$_POST['friendsname'];
$friendsemail=$_POST['friendsemail'];
$friendsphone=$_POST['friendsphone'];
$autoreply="Dear $friendsname,

Your friend, $name, thinks you might be interested in the Au Pair program. Click on this link below to view our official website:

http://www.thaiaupair.com

We look forward to welcoming both you and your friend to a new life experience abroad!

Thai Au Pair Team

สวัสดีค่ะ

เพื่อนของคุณชื่อ $name แนะนำเราว่าคุณอาจจะสนใจหนึ่งในโครงการไทยออแพร์ และแจ้งให้เราส่งอีเมลล์ให้กับคุณนะคะ

คุณสามารถค้นหารายละเอียด หรือข้อมูลเพิ่มเติมของโครงการต่างๆ ได้ที่

http://www.thaiaupair.com

ทีมงานหวังเป็นอย่างยิ่งที่จะได้ตอบข้อสักถามเพิ่มเติม และได้นำเสนอโอกาสในการได้เรียนรู้การใช้ชีวิตในต่างแดนให้แก่คุณนะคะ ขอบคุณค่ะ";

$subject="Thaiaupair.com-You've been referred to us by $name.";
mail($friendsemail, $subject, $autoreply);

$formcontent = "Name: $name 
 Email: $email 
 Phone: $phone 
 Friend's Name: $friendsname 
 Friend's Email: $friendsemail 
 Friend's Phone: $friendsphone";
$recipient = "info@thaiaupair.com";
$subject = "Refer A Friend";
mail($recipient, $subject, $formcontent) or die("Error!"); 

echo '<img src="http://thaiaupair.com/Image/logophp.png" padding-bottom:10px>';
echo "<br>";
echo "<br>";
echo "Thank you for referring your friend to us!" . " -" . "<a href='Tell-A-Friend.html' style='text-decoration:none; color:#df2590;'> Return Home</a>";
?>

The OUPUT I get in my email is not Thai, like this:

Name: ทท 
Email: ทท 
Phone: ทท 
Friend's Name: ทท 
Friend's Email: ทท 
Friend's Phone: ทท

I checked my encoding setting for all the parts I know (I don't know a lot right now, to be honest), like all the Page Properies are set to:

Document Type: XHTML 1.0 Transitional
Encoding: Unicode (UTF-8)
Unicode Normalization Form: C

I already us the meta tag: as suggested in many websites I tried to learn from.

I now wonder if I should add something on my PHP code? Please help. I need to learn this the right way. Thank you so very much,

Chili

EDIT: I found out that the problem is not with my code at all. It's the Roundcube (email provider) settings. I only needed to change the encoding in Roundcube to utf-8 and it finally works!!

  • 写回答

1条回答 默认 最新

  • doudang9147 2015-07-11 07:03
    关注

    Use headers in e-mail

    $headers = "MIME-Version: 1.0
    ";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1
    ";
    mail($email, $subject, $autoreply, $headers);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么