2013-03-01 35 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