【发布时间】:2013-06-08 19:47:33
【问题描述】:
我尝试了许多标题更改都无济于事。
可能是电子邮件服务器吗?还是我错过了一些重要的东西?
我希望看到的不仅仅是在生成的电子邮件中呈现为文本的代码。
谢谢!
<?php session_start(); ?>
<?php
$body = '';
$body .= '<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Shopping Cart</title>
</head>
<body>
<h1>Here is a Copy of Your Order</h1>';
$body .= '<table>
<tr>
<th>Product</th>
<th>Cost</th>
<th>Units</th>
<th>Subtotal</th>
</tr>';
$total = 0;
foreach($_SESSION['cart'] as $item) {
$body .= "<tr>
<td>{$item['item']}</td>
<td>\${$item['unitprice']}</td>
<td>{$item['quantity']}</td>
<td>$".($item['unitprice'] * $item['quantity'])."</td>
</tr>";
$total += ($item['unitprice'] * $item['quantity']);
}
$body .= '</table>';
$body .= "<p>Grand total: \$$total</p>";
$body .='</body></html>';
}
?>
<?php
echo $body;
$to = 'xxxx@gmail.com';
$subject = 'Fill This Order';
$headers = 'From: xxxx@gmail.com' . PHP_EOL;
$headers .= 'MIME-Version: 1.0' . PHP_EOL;
$headers .= 'Content-type: text/html; charset=iso-8859-1' . PHP_EOL;
mail($to, $subject, $message, $body, $headers);
?>
【问题讨论】:
-
邮件客户端可以接收HTML邮件吗?你试过
imap_mail()吗?您尝试过哪些标头? -
您好 cmt,我认为这可能是电子邮件客户端问题。我会尝试 imap_mail() 并报告。
-
出于好奇,您为什么不使用可用于为您发送电子邮件的 mirad 库之一?