我编写了这个 PHP 脚本来发送 HTML 电子邮件。但是,电子邮件输出显示为原始文本,而不是被解释为 html。
<?php
if(isset($_POST['submit'])) {
$to = $_POST['email'];
$from = "info@test.com";
$subject = "subject";
$message = "<div style=\"background:red;height:100px; " .
"width:100px;display:block;\">dfsdf</div>";
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: $from\r\n";
mail($to, $subject, $message, $headers);
echo "Message has been sent....!";
}else{
echo "Add an email address";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="/send" method="post">
<input name="email" type="text" />
<input name="submit" type="submit" value="Submit">
</form>
</body>
</html>
我收到的电子邮件是:
<div style="background:red;height:100px;width:100px;display:block;">dfsdf</div>
我希望得到一个红色的盒子。我究竟做错了什么?