1

我有反馈表。我想用 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>

请问,有什么想法吗?

4

4 回答 4

1
  /** 
   * 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); 
  } 

有关更多信息,请查看此链接

于 2013-08-24T08:32:36.700 回答
0

在你的 html 页面中添加这个 head 标签:

<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>
于 2013-01-23T11:59:51.807 回答
0

我认为您必须将其添加到 phpmailer

$mail->CharSet = 'UTF-8';       
$mail->Encoding     = "base64";
于 2020-08-19T14:34:27.023 回答
0

在 mysql 设置中使用 utf8_general_ci 对您的数据库进行编码。

于 2021-03-04T15:45:42.520 回答