首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Wordpress中通过mail-form发送邮件中的奇怪信件

在Wordpress中通过mail-form发送邮件中的奇怪信件
EN

Stack Overflow用户
提问于 2013-03-01 20:31:44
回答 1查看 171关注 0票数 0

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

我需要包括这些字母:?、?

现在,它在发送邮件时输出的字母是†、˜,而不是上面的字母。

邮件表单的php是:

代码语言:javascript
复制
<?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(); ?>
EN

回答 1

Stack Overflow用户

发布于 2013-03-01 23:03:49

有更多地方可能会出现此问题,但首先验证是否:

  1. MySQL 5不支持完整的UTF-8字符
  2. 电子邮件客户端/主机不支持完整的UTF-8字符

这很容易验证,检查你的网站/数据库,如果你在那里检测到这个问题,那么你可以尝试使用this plugin或搜索类似的问题。

不好的部分是,问题可能来自电子邮件客户端(例如: thunderbird或outlook),甚至来自电子邮件主机。我遇到了一些语言特定字符的问题,这些字符在yahoo和gmail webmail中都显示得很好,但在任何圆形主机上都不显示。我最终用“普通”字符代替了我的字符。(我还没有尝试ubove插件)。

检查插件,它说它会重新编码字符,所以它应该可以做到这一点。

致以问候。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15157852

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档