2013-01-23 58 views
1

我有反饋表格。我想發送HTML郵件中的內容。當用戶輸入阿拉伯字符時,它不顯示正確。像تجرOO©用阿拉伯語支持發送電子郵件php

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:[email protected]\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> 

請問,有什麼想法嗎?

+0

大部分時間,它更方便,更容易地使用現有的PHP的一個圖書館發送電子郵件 - 他們已經以正確的方式實施了這些案例(http://swiftmailer.org/,https://code.google.com/a/apache-extras.org/p/phpmailer/) –

+0

提交時使用'escape'關鍵字 – Tarika

回答

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> 
+0

我已經把這個meta標籤放在頭部 這一頁。我現在在HTML表單中添加了另一個,並且我仍然有發送電子郵件的相同錯誤 – Kamal

+0

,此電子郵件與頁面無關。所以你必須添加這個html-header到你的email-html($ msg) –

+0

我試過了。它不工作。我也嘗試回覆表單提交的POST變量,並顯示與郵件相同的問題。 – Kamal

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

+0

Assalamu alikoom brorthor khaled.alshamaa,我播下你的網站(ar-php.org) 。你可以請在YouTube上做教程如何使用它?如果您需要任何幫助,請告訴我 - Jazak Allahu Khiran –