用阿拉伯语支持发送电子邮件php

时间:2013-01-23 11:55:23

标签: php sendmail arabic

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

答案 0 :(得分:0)

在您的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>

答案 1 :(得分:0)

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

有关详细信息,请查看此link

答案 2 :(得分:0)

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

$mail->CharSet = 'UTF-8';       
$mail->Encoding     = "base64";

答案 3 :(得分:0)

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