-2

以下代码发送的邮件包含所有 HTML 标签。我怎样才能摆脱这种尝试了几种方法,但邮件输出仍然被 html 标签打乱。如果有更好的方式发送元素数组,还需要帮助mail();

我的代码:

<?php
    include('Mail.php');
    include('mail\mime.php');

    $errors=array();
    if(empty ($_POST)===false)
    {
        //$product = $_POST['product'];
        //$quantity = $_POST['quantity'] ;
        $email="noreply@cortexonline.in";
        $item1 = $_POST['product']['1'];
        $item2 = $_POST['product']['2'];
        $item3 = $_POST['product']['3'];
        $item4 = $_POST['product']['4'];
        $item5 = $_POST['product']['5'];
        $quan1 = $_POST['quantity']['1'];
        $quan2 = $_POST['quantity']['2'];
        $quan3 = $_POST['quantity']['3'];
        $quan4 = $_POST['quantity']['4'];
        $quan5 = $_POST['quantity']['5'];
        $message = "<html><head><title></title>
            </head> <body> <table> 
                <tr><td>Shop id=</td>
                </tr><tr><td>Product Name</td>
                    <td>Quantity</td></tr>
                <tr><td>".$item1."</td>
                    <td>".$quan1."</td></tr>
                <tr><td>".$item2."</td>
                    <td>".$quan2."</td></tr>
                <tr><td>".$item3."</td>
                    <td>".$quan3."</td></tr>
                <tr><td>".$item4."</td>
                    <td>".$quan4."</td><td>".$item5."</td><td>".$quan5."</td></tr>
            </table></body></html>";
        $header = 'From: "Quick order" <noreply@cort.in>'.PHP_EOL.
            'Reply-to: <noreply@cort.in>'.PHP_EOL.
            'MIME-Version: 1.0'.PHP_EOL.
            'Content-Type: text/plain; charset=utf-8'.PHP_EOL.
            'Content-Transfer-Encoding: 8bit'.PHP_EOL.
            'X-Mailer: PHP/'.PHP_VERSION.PHP_EOL;

   if(ctype_alpha($quan1)===true||ctype_alpha($quan2)===true||ctype_alpha($quan3)==true||ctype_alpha($quan4)===true||ctype_alpha($quan5)===true)
    {
        $errors[]=' Quantity cannot be alphabet /n
            Cannot send request';
    }

    if(isset($_POST['send'])===true)
    {       
        if (empty($errors)===false)
        {
            echo '<script language="javascript">alert("NOT SENT! Qunatity cannot be Alphabet")</script>';
        }
        else
        {
            mail('order@cortexonline.in','Quick order',$message,$header);

            echo '<script language="javascript">alert("Your order sent!")</script>';
            echo '<script language="javascript">window.location = "index.php"</script>';
        }
    }
    else
    {
        echo '<script language="javascript">alert("ORDER NOT SENT! Please Try Again.")</script>';
        echo '<script language="javascript">window.location = "index.php"</script>';
    }
}
?> 

还尝试使用单引号它不起作用。

4

1 回答 1

2

尝试这个:

$header = 'From: "Quick order" <noreply@cort.in>'.PHP_EOL.
            'Reply-to: <noreply@cort.in>'.PHP_EOL.
            'MIME-Version: 1.0'.PHP_EOL.
            'Content-Type: text/html; charset=utf-8'.PHP_EOL.
            'Content-Transfer-Encoding: 8bit'.PHP_EOL.
            'X-Mailer: PHP/'.PHP_VERSION.PHP_EOL;
于 2013-05-04T15:05:21.460 回答