0

我需要更改这边使用的邮件表单的字符集: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(); ?>
4

1 回答 1

0


有更多地方可能会出现此问题,但首先验证是否:
1. MySQL 5 不支持完整的 UTF-8 字符
2. 电子邮件客户端/主机不支持完整的 UTF-8 字符

很容易验证如果您在那里检测到此问题,请检查您的网站/您的数据库,然后您可能会尝试使用此插件或搜索类似的插件。

不好的部分是问题可能来自电子邮件客户端(例如:thunderbird 或 Outlook),甚至来自电子邮件主机。我遇到了一些语言特定字符的问题,这些字符在 yahoo 和 gmail webmail 中都显示得很好,但在任何圆形立方体主机中都没有。我最终用“正常”的角色替换了我的角色。(我还没有尝试过 ubove 插件)。
检查它说它重新编码字符的插件,所以它应该可以解决问题。
问候。

于 2013-03-01T15:03:49.367 回答