我正在使用以下代码通过 php 发送 html 电子邮件,请检查我做错的以下代码。它发送电子邮件但不是 html 格式,我尝试了很多网上可用的示例,但无法获得 html 格式的电子邮件。请在这方面帮助我。
require_once "Mail.php";
$name="Me";
$mail_from="info@domain.com";
$subject=$mail_from." Emails";
$message = "
<html>
<body bgcolor=#DDDDDD>
YOUR HTML EMAIL
</body>
</html>
";
$From="from: $name <$mail_from>";
$headers = "From: $From\r\n";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$to = "Shop <info@domain.com>";
$from = "Contact $name <info@domain.co.uk>";
$host = "mail.exclusivehosting.net";
$username = "info@domain.co.uk";
$password = "(hello)";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $message);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
//echo("<p>Message successfully sent!</p>");
echo'<table width="800" border="0" align="center" >
<td>';
echo "We've recived your contact information, we will get back soon!";
echo'</td>
</table>';
}
因为我收到以下电子邮件
<html>
<body bgcolor=#DDDDDD>
YOUR HTML EMAIL
</body>
</html>