我有反馈表。我想以HTML邮件发送内容。当用户输入阿拉伯字符时,它不会正确显示。类似 ØªØ¬Ø±Ø ̈Ø©
PHP代码:
function send_email($fromPerson, $fromEmail, $to, $subject, $message) {
$headers = "From: $fromPerson<$fromEmail> 'n";
$headers .= "Reply-To: $eMail 'r'n";
$headers .= "X-Mailer: PHP/". phpversion();
$headers .= "X-Priority: 3 'n";
$headers .= "MIME-version: 1.0'n";
$headers .= "Content-Type: text/html; charset=UTF-8'n";
$headers .= "Bcc:log@tazbeta.com'n";
$msg=$message;
@mail($to, $subject, $msg, $headers);
我尝试直接从 php 代码发送阿拉伯语,它正确到达,有些东西像$msg = "مثال";
问题是当我从反馈代码提交内容时。
<form name="feedb" method="post" action="subscribe.php" onsubmit="return validate_forms();">
<input type="hidden" name="feedback_action" value="feed" />
<div class="fr" style="width:378px;">
<p class="white fs24 mb4">Give Us Your Valuable Feedback</p>
<input name="firstName" id="firstName" type="text" style=" background:#fff; padding:5px; border:none; width:174px; color:#000; font-size:13px;" value="Full Name" onfocus="if(this.value=='Full Name')this.value=''" onblur="if(this.value=='')this.value='Full Name'" />
<input name="email" id="email" type="text" style=" background:#fff; padding:5px; border:none; width:174px; color:#000; font-size:13px; margin-left:5px;" value="Email ID" onfocus="if(this.value=='Email ID')this.value=''" onblur="if(this.value=='')this.value='Email ID'" />
<div class="cb pb8"></div>
<textarea name="comments" id="comments" rows="3" cols="50" style=" background:#fff; padding:5px; border:none; width:366px; color:#000; font-size:13px;" onfocus="if(this.value=='Feedback')this.value=''" onblur="if(this.value=='')this.value='Feedback'">Feedback</textarea>
<div class="ar mt6">
<input type="hidden" name="source" value="feedback" />
<input name="submit" type="image" src="images/sbmt.gif" />
</div>
</div>
</form>
拜托,有什么想法吗?
/**
* Simple UTF-8 mail sender function. This function also encode subject and
* plain-text message to UTF-8. If you need HTML mail sender, change the code
* in line 2 from text/plain to text/html, but this function is usable the
* most cases without any modification.
*/
function mail_utf8($to, $subject = '(No subject)', $message = '', $header = '') {
$_header = "MIME-Version: 1.0'r'nContent-type: text/plain; charset=UTF-8'r'n";
mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $_header . $header);
}
有关更多信息,请查看此链接
我认为你必须把它添加到phpmailer中
$mail->CharSet = 'UTF-8';
$mail->Encoding = "base64";
在你的HTML
页面中添加这个头标签:
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
</head>
<body>
<form name="feedb" method="post" action="subscribe.php">
...
</form>
</body>
在 mysql 设置中使用 utf8_general_ci 对数据库进行编码。