在Wordpress中从邮件表单发送的邮件中的奇怪信件

时间:2013-03-01 12:31:44

标签: php wordpress wordpress-theming

我需要更改此方使用的邮件表格的字符集:http://www.erik-dalsgaard.dk/kontakt/

我需要包括这些字母:Æ,æ,Ø,ø,Å,å

现在发送邮件时输出的字母是Æ,Ã,Ã而不是上面的字母。

邮件形式的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._%-]+@[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(); ?>

1 个答案:

答案 0 :(得分:0)


有更多地方可能会出现这个问题,但是如果出现以下情况,请先核实:1。 MySQL 5不支持完整的UTF-8字符
2。电子邮件客户端/主机不支持完整的UTF-8字符

很容易验证这一点,检查您的网站/数据库,如果您发现此问题,那么您可能会尝试使用this plugin或搜索类似的内容。

不好的部分是问题可能来自电子邮件客户端(例如:thunderbird或outlook),甚至来自电子邮件主机。 我遇到了一些语言特定字符的问题,这些字符在yahoo和gmail webmail中都很好,但在任何圆形主机中都没有。我最后用“普通”插件替换了我的字符。(我没有尝试过ubove插件)。
检查插件,它说它重新编码了字符,所以应该这样做。
问候。 / p>