奇怪的事情发生在我身上。我试图发送一个HTML邮件,使用php mail()
函数,但在这里没有运气。即使我从字面上复制/粘贴一段代码,它也不起作用。我究竟做错了什么?下面是一段代码我使用:使用PHP邮件发送HTML邮件失败()
$message = "<html><body>";
$message .= "<table rules='all' style='border-color: #666;' cellpadding='10'>";
$message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td></tr>";
$message .= "</table>";
$message .= "</body></html>";
$to = '[email protected]';
$subject = 'Website Change Reqest';
$headers = "From: " . $email . "\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if (mail($to, $subject, $message, $headers)) {
echo 'Your message has been sent.';
} else {
echo 'There was a problem sending the email.';
}
而这正是我的电子邮件看起来象...:
Reply-To: [email protected]
MIME-Version: 1.0
Content-Type: text/html; charset=ISO-8859-1
Message-Id: <[email protected]>
Date: Mon, 4 Jul 2011 01:45:51 +0200 (CEST)
<html><body><table rules="all" style="border-color: #666;" cellpadding="10"><tr style='background: #eee;'><td><strong>Name:</strong> </td></tr><tr><td><strong>Email:</strong> </td></tr><tr><td><strong>Type of Change:</strong> </td></tr><tr><td><strong>Urgency:</strong> </td></tr><tr><td><strong>URL To Change (main):</strong> </td></tr><tr><td><strong>NEW Content:</strong> </td></tr></table></body></html>
我该怎么办错了吗?
哪种操作系统,你用? –
Mac OS X 10.7和我的电子邮件客户端是Sparrow – Michiel