我想通过PHP以HTML格式发送电子邮件,下面显示的代码为我提供了下一个问题:mailscript实际上正在工作但是当邮件到达并且我打开它时,邮件以html代码显示。我实际上想让HTML代码在邮件中工作。
<?php
$headers = "From: " . strip_tags($_POST['emailadres']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($to) . "\r\n";
$headers .= "CC: ".$to."\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= '<img src="//css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['voornaam']) . "</td></tr>";
$message .= "<tr>
<td>
Vraagsteller
</td>
<td>
".$_POST['voornaam']."
</td>
</tr>";
$message .= "<tr>
<td>
From
</td>
<td>
".$from."
</td>
</tr>";
$message .= "<tr>
<td>
Titel
</td>
<td>
".$subject."
</td>
</tr>";
$message .= "<tr>
<td>
Activatie link
</td>
<td>
Link
</a>
</td>
</tr>";
$message .= "<tr>
<td>
Privacy
</td>
<td>
".checkPrive()."
</td>
</tr>";
?>
答案 0 :(得分:0)
试试这个
$to="abc@domain.com";
// Your subject
$subject="$sub";
// From
$from = "xyz@domain.com";
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: <".$from.">\n";
$headers .= "CC: cc@domain.com\r\n";
$headers .= "X-Priority: 1\n";
// Your message
$message= $text;
$send=mail($to,$subject,$message,$headers);