PHP联系表单在网站中不发送日文字符

时间:2014-02-19 21:17:16

标签: php utf-8

我正在使用一个发送到电子邮件的简单php联系表单,但是当我希望它发送日语字符时,我从表单收到的电子邮件会显示那些带有奇怪的希腊语代码的字符。我假设有一些方法可以在php表单中指定我使用的是UTF-8,但是我不确定将字符显示为日语的位置或内容。下面是代码。

<?php
    if(isset($_POST['email'])) {
        // EDIT THE 2 LINES BELOW AS REQUIRED
        $email_to = "abc@abc.com";
        $email_subject = "Contact Form";

        // validation expected data exists
        if(!isset($_POST['first_name']) ||
            !isset($_POST['email']) ||
            !isset($_POST['telephone']) ||
            !isset($_POST['comments'])) {
            died('We are sorry, but there appears to be a problem with the form you submitted.');      
        }

        $first_name = $_POST['first_name']; // required
        $email_from = $_POST['email']; // required
        $telephone = $_POST['telephone']; // not required
        $comments = $_POST['comments']; // required
        $email_message = "Form details below.\n\n";

        function clean_string($string) {
            $bad = array("content-type","bcc:","to:","cc:","href");
            return str_replace($bad,"",$string);
        }

        $email_message .= "First Name: ".clean_string($first_name)."\n";
        $email_message .= "Email: ".clean_string($email_from)."\n";
        $email_message .= "Telephone: ".clean_string($telephone)."\n";
        $email_message .= "Comments: ".clean_string($comments)."\n";

        // create email headers
        $headers = 'From: '.$email_from."\r\n".
        'Reply-To: '.$email_from."\r\n" .
        'X-Mailer: PHP/' . phpversion();
        @mail($email_to, $email_subject, $email_message, $headers); 
?>

<!-- include your own success html here -->

0 个答案:

没有答案