Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP使用utf-8发送带有问号的邮件_Php_Email_Utf 8 - Fatal编程技术网

PHP使用utf-8发送带有问号的邮件

PHP使用utf-8发送带有问号的邮件,php,email,utf-8,Php,Email,Utf 8,使用以下php文件发送邮件。 但是邮件正文里面不是英文的文本得到了吗????邮件的$主题为“Ã:ƒƒƒƒƒƒƒƒ«Ã” 我需要检查/添加/更改什么才能修复它 <?php include('config.php'); header('Content-Type: text/html; charset=utf-8'); class messenger { public $name; public $number; public $email; public $

使用以下php文件发送邮件。 但是邮件正文里面不是英文的文本得到了吗????邮件的$主题为“Ã:ƒƒƒƒƒƒƒƒ«Ã”

我需要检查/添加/更改什么才能修复它

<?php include('config.php');
header('Content-Type: text/html; charset=utf-8');

class messenger
{

    public $name;
    public $number;
    public $email;
    public $address;
    public $category;
    public $tool;

    /*----------user registration start--------------*/
    function signup()
    {

        $name = $_REQUEST['name'];
        $number = $_REQUEST['number'];
        $email = $_REQUEST['email'];
        $address = $_REQUEST['address'];
        $category = $_REQUEST['category'];
        $tool = $_REQUEST['tool'];
        $datetime = date("Y-m-d H:i:s");

        //Generate the email message:
        $to = 'someEmailAddress@gmail.com';
        $subject = "הזמנת חדשה";
        $msg = "In time: " . $datetime . "\n New Power Tool Rental: \n\n            Name: " . $name . "\r\n            Email: " . $email . "\n            Mobile Number: " . $number . "\n            Address: " . $address . "\n            Category: " . $category . "\n            Tool: " . $tool . "\n\n Regards\n " . $name . " \n " . $email;
        $headers = "From:  $email" . "\r\n";
        $headers .= "MIME-Version: 1.0" . "\r\n";
        $headers .= "Content-type: text/plain; charset=UTF-8";
        $headers .= "X-Mailer: PHP/" . phpversion();

        //Send the email
        mail($to, $subject, $msg, $headers);

        //Enter data to the SQL table
        $sql = "INSERT INTO user (name, number, email, address, category, tool, dateTime)
                 VALUES ('$name', '$number', '$email', '$address', '$category', '$tool','$datetime')";

        //Check if entered to SQL and if Yes send back in json message
        $result = mysql_query($sql);
        if (!$result) {
            $message["result"] = "Problemmm";
        } else {
            $mysql_insert_id = mysql_insert_id();       //get the new ID number from sql table
            $message["id"] = $mysql_insert_id;          //add the new ID data to the response message
            $message["name"] = $_REQUEST['name'];
            $message["number"] = $_REQUEST['number'];
            $message["email"] = $_REQUEST['email'];
            $message["address"] = $_REQUEST['address'];
            $message["result"] = "successfully";
        }

        //Send back the json message
        echo json_encode($message);
        die;
    }
    /*----------user registration end--------------*/
}

?>
现在我得到邮件的主题是:
���ú ��é ��

设置标题是不够的

主题
(必须)和
消息
(在您的情况下必须是UTF-8)也有相应的正确编码,php::doc+用户说明涵盖了您错过的大部分内容。

非英语文本可能不一定是UTF-8,但可能是另一种字符编码。您可以查看iconv以将其转换为utf-8。此外,内容类型为utf-8不会影响主题,请参阅本节了解如何将主题编码为utf-8
$subject = "הזמנת כלי להשכרה";
$encSubject = '=?UTF-8?B?'.base64_encode($subject).'?=';