[英]How to send Cyrillic data from e-mail php contact form?
我在我的網站上使用了一個php聯系人表單,但我想啟用該表單以接受Cyrilic字母,因為現在如果我使用cyrilic,我會在此郵件上重新輸入以下字符:
這是我的腳本:
<?php
// load the variables form address bar
$subject = $_POST["subject"];
$message = $_POST["message"];
$from = $_POST["from"];
$verif_box = $_POST["verif_box"];
// remove the backslashes that normally appears when entering " or '
$message = stripslashes($message);
$subject = stripslashes($subject);
$from = stripslashes($from);
// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
// if verification code was correct send the message and show this page
mail("you@email.com", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from");
// delete the cookie so it cannot sent again by refreshing this page
setcookie('tntcon','');
} else if(isset($message) and $message!=""){
// if verification code was incorrect then return to contact page and show error
header("Location: index.php?subject=$subject&from=$from&message=".urlencode($message)."&wrong_code=true");
exit;
} else {
echo "no variables received, this page cannot be accessed directly";
exit;
}
?>
看來您的郵件是以utf-8格式提交的。 將以下標頭添加到您的郵件中:
Content-Type: text/plain; charset=utf-8
用1個換行符將其與“發件人” "From: $from\\nContent-Type: ..."
,即"From: $from\\nContent-Type: ..."
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.