发送邮件后带问号的php钻石

时间:2012-11-13 07:46:11

标签: php

我有一个显示考试的PHP页面(希伯来文),它正确显示,在底部我有一个自己的发送邮件按钮。

问题是我把邮件发送给我自己的邮件之后用希伯来文邮件但是我看到的一些信件"�"

charset它:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

我的标题字符集也是UTF-8,我也尝试ISO-8859-1,但它给了我相同的。

最奇怪的是当我将标题字符集更改为Big5(中文)时,我需要在我的电子邮件中看到乱码,但我看到同样的消息

1 个答案:

答案 0 :(得分:0)

这是我的代码:

$content = 
    writeExamDetails() .
    writeStudnetDetails() .
    writeAnswers($numOfQuestions);

    if ($_POST['studentComments']!=null) {
        $content .= "<p align=\"" . $text['align'] . "\"><strong>" . 
                    $text['studentComments'] .
                    ":</strong><br />" .
                    formatStr($_POST['studentComments']) . 
                    "</p>";
    }

    $body = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" >
    <html>
    <head>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />
    <title>" . 
    $text['emailResultsPageTitle'] . 
    "</title>
    <style>
    body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.9em;
    direction: " . $text['dir'] . ";
    text-align: " . $text['align'] . ";
    }
    </style>
    </head>
    <body>
    <p dir=\"ltr\" style=\"color:#999999;\">
    If you cannot view the following contents properly, change the Encoding to Unicode (UTF-8).</p>" .
    $content;

    $body .= "<hr noshade=\"noshade\" height=\"1\" /><p>" . 
            $text['emailResultsDurationTitle'] . ": " . 
            duration((int)($_POST['lapsedTime']/1000)) .
            "</p>
            </body>
            </html>";

    $subject = "" . trim(stripslashes(stripslashes($_POST['examTitle'])));
                //formatStr2html($_POST['examTitle']);
    if (isset($_POST['studentId'])){
        $subject .= " (ID: " . $_POST['studentId'] . ")";
    }

    $headers = "From: " . $from . "\n" . $cc . 
                "Subject: " . $subject ."\n" .
                "X-Mailer: PHP/" . phpversion() . "\n" .
                "MIME-Version: 1.0\n" .
                "X-Priority: 1\n" . "Importance: High\n" . "X-MSMail-Priority: High\n" .
                "Content-Type: text/html; charset=iso-8859-1\n";
                "Content-Transfer-Encoding: 8bit\r\n\r\n";



    $result = mail ($to, $subject, $body, $headers);

这就是它在希伯来语中的表现(我希望你理解希伯来语)

浏览器中的

(正确)---&gt; “אחתשתיםבדיקהאחתשתיםבדיקה”

在电子邮件中(不正确)---&gt; “אחתשת םבדיקהאחתשתיםבדי קה”