我有以下 php 代码:
<?php
header('Content-Type: text/html; charset=utf-8');
if (isset($_POST['email']))
//if "email" is filled out, send email
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent="<html><body>
<span style='background-color: #cdcdcd'>
text: $name
</span>
text: $phone
<span style='background-color: #cdcdcd'>
text: $email
</span>
text: $message </html><body/>";
$recipient = "email@email.com";
$subject = "text text text ";
$headers = "From: $email" . "\r\n" .
"Reply-To: $email" . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($recipient, $subject, $formcontent, $headers) or die("Error!");
echo "Thank You!";
?>
问题是当我收到电子邮件时,我看到电子邮件正文中的所有 HTML 标记,并且电子邮件没有样式。
我的问题是我该如何解决?