2013-03-01 72 views
0

從郵件的形式發送,我需要改變這一邊用郵件形式的字符集:http://www.erik-dalsgaard.dk/kontakt/奇怪的字母WordPress的

我需要包括這些信件:AE,æ,O,O,A ,å

現在它發送郵件時輸出的字母是Æ,Ã,Ã,而不是上面的字母。

爲mailform的PHP是:

<?php 



/* 
Template Name: Contact 
*/ 

get_header(); ?> 


<?php 


//If the form is submitted 
if(isset($_POST['submitted'])) { 

    //Check to make sure that the name field is not empty 
    if(trim($_POST['contactName']) === '') { 
     $nameError = 'You forgot to enter your name.'; 
     $hasError = true; 
    } else { 
     $name = trim($_POST['contactName']); 
    } 

    //Check to make sure sure that a valid email address is submitted 
    if(trim($_POST['email']) === '') { 
     $emailError = 'You forgot to enter your email address.'; 
     $hasError = true; 
    } else if (!eregi("^[A-Z0-9._%-][email protected][A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { 
     $emailError = 'You entered an invalid email address.'; 
     $hasError = true; 
    } else { 
     $email = trim($_POST['email']); 
    } 

    //Check to make sure comments were entered 
    if(trim($_POST['comments']) === '') { 
     $commentError = 'You forgot to enter your comments.'; 
     $hasError = true; 
    } else { 
     if(function_exists('stripslashes')) { 
      $comments = stripslashes(trim($_POST['comments'])); 
     } else { 
      $comments = trim($_POST['comments']); 
     } 
    } 

    //If there is no error, send the email 
    if(!isset($hasError)) { 

     $emailTo = get_option_tree('pr_contact_email'); 
     $subject = 'Henvendelse fra hjemmeside fra '.$name; 
     $msubject = trim($_POST['subject']); 
     $body = "Navn: $name \n\nE-Mail: $email \n\nEmne: $msubject \n\nBesked: $comments"; 
     $headers = 'From: Besked fra hjemmeside <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; 

     mail($emailTo, $subject, $body, $headers); 

     $emailSent = true; 

    } 
} 
?> 
<?php get_header(); ?> 

<div class="inner custom_content"> 

    <div class="content <?php global_template(content); ?>"> 

     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>      

     <?php if(the_content()){ ?> 
     <div class="divider"></div> 
     <?php } ?> 

     <?php endwhile; endif; ?> 

    <?php if(isset($emailSent) && $emailSent == true) { ?> 

    <div class="form-success"> 
     <?php echo get_option_tree('pr_form_success'); ?> 
    </div> 

    <?php } else { ?> 

    <div class="form-success"> 
     <?php echo get_option_tree('pr_form_success'); ?> 
    </div> 

     <form action="<?php the_permalink(); ?>" id="contactForm" class="big_form" method="post" accept-charset="UTF-8"> 

      <ul class="forms"> 
       <li> 
        <label for="contactName">Navn: *</label> 
        <input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" class="requiredField <?php if($nameError != '') { ?>hightlight<?php } ?>" /> 


       </li> 

       <li><label for="email"><?php tr_translate(email); ?>: *</label> 
        <input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" class="requiredField email <?php if($emailError != '') { ?>hightlight<?php } ?>" />      

       </li> 

       <li><label for="subject">Emne:</label> 
        <input type="text" name="subject" id="subject" value="<?php if(isset($_POST['subject'])) echo $_POST['subject'];?>" />     

       </li> 

       <li class="textarea"><label for="commentsText">Besked: *</label> 
        <textarea name="comments" id="commentsText" rows="8" cols="60" class="requiredField <?php if($commentError != '') { ?>hightlight<?php } ?>"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?></textarea> 
       </li>    
       <li class="buttons"> 
        <input type="hidden" name="submitted" id="submitted" value="true" /> 
        <button type="submit" class="button light"><?php tr_translate(submit_contact); ?></button> 
        <div class="loading"></div> 
       </li> 
      </ul> 
     </form> 

    </div><!-- .content End --> 
    <!-- Content End -->  

<?php } ?> 

<?php global_template(sidebar); ?> 

<?php get_footer(); ?> 

回答

0


還有更多的地方,這個問題可能會來,但拳頭驗證是否:
1. MySQL的5不支持全UTF-8字符
2。電子郵件客戶端/主機不支持完整的UTF-8字符

很容易驗證這一點,檢查您的網站/您的數據庫,如果你在那裏也發現這個問題,那麼你可以嘗試使用this plugin或搜索類似的。

不好的部分是問題可能來自電子郵件客戶端(例如:thunderbird或Outlook)或甚至來自電子郵件主機。 我用一些語言特定的字符來處理問題,這些字符在雅虎和gmail網絡郵件中都顯示得很好,但在任何一個圓形主機中都沒有。我最終用「普通」字符取代了我的角色(我沒有嘗試過這個插件)。
檢查插件說它重新編碼的字符,所以它應該做的伎倆。
關心。

+0

UFT-8支持所有地方。 我會嘗試插件,看看它是否可以幫助我改變正在發送的電子郵件的輸出。 Thanx – DWTBC 2013-03-02 19:30:15