以下代碼發送的郵件包含所有HTML標籤。我怎樣才能擺脫那種嘗試了幾種方式,但仍然郵件輸出與html標籤混雜在一起。同時還需要發送,如果元素的數組的任何更好的方法幫助通過mail();
無法通過郵件發送HTML郵件()
我的代碼:
<?php
include('Mail.php');
include('mail\mime.php');
$errors=array();
if(empty ($_POST)===false)
{
//$product = $_POST['product'];
//$quantity = $_POST['quantity'] ;
$email="[email protected]";
$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" <[email protected]>'.PHP_EOL.
'Reply-to: <[email protected]>'.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('[email protected]','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>';
}
}
?>
使用它不靈單引號也試過。
歡迎StackOverflow上。大寫字母通常無法幫助您獲得更好的答案。格式良好的問題有助於獲得更好的答案。 ;-) – TheHippo 2013-05-04 15:05:33
哈哈,我剛剛注意到他的頭銜是在帽子裏。但是,我不得不承認這讓我注意到這個問題更好一些。 – 2013-05-04 15:06:38