我正在继续开发以前开发人员的网络,允许用户发送查询表单。一些用户是中国人,因此他们在填写表格时倾向于使用汉字。当他们发送表格时,我收到的电子邮件将显示此内容
å ‰éš†å ¡/雪兰莪州
有没有办法解决这个问题?这是代码
query_process.php:
<?php
session_start();
require_once "includes/phpmailer.php";
$name = mysql_real_escape_string($_POST['name']);
$email = mysql_real_escape_string($_POST['email']);
$subject = mysql_real_escape_string($_POST['subject']);
$message = mysql_real_escape_string($_POST['message']);
$subject = "[Website] Contact Form";
$body = "<p>Name: $name</p>
<p>Email: $email</p>
<p>Subject: $subject</p>
<p>Message : $message</p>
";
//$cf_mail_replyto
if(sendPHPMail('___', '___', '___', $subject, $body))
echo "success";
else
echo "fail";
?>
query_from.php:
...
function submitForm()
{
if($("#name").val() == "")
alert("Sorry, please fill in your name.");
else
if($("#email").val() == "")
alert("Sorry, please fill in your email.");
else
if($("#subject").val() == "")
alert("Sorry, please fill in your subject.");
else
if($("#message").val() == "")
alert("Sorry, please fill in your message.");
else
{
$.ajax({
type: "POST",
url: "query_process.php",
data: $("#enquiry").serialize(),
success: function(data){
if(data == "success"){
alert("Your enquiry has been sent successfully.");
window.location.reload();
}
else{
//console.log(data);
//alert(data);
alert("There's problem sending your enquiry. Please try again later.");
}
}
});
}
}
...
</script>
//my form
...
- 不要再使用 MySQL 扩展
- 您到底为什么要在电子邮件上下文中使用mysql_real_escape_string
- 您使用什么电子邮件查看器
sendPHPMail
函数中到底有什么?这是phpmailer
类的包装器吗?检查 无法使用 PHPMailer 发送带有正确字符的电子邮件,了解如何使用phpmailer
发送 UTF-8 邮件。- 包含表单的 HTML 页面是否具有适当的 UTF-8 编码?