[英]Why is the HTML not being interpreted in this e-mail?
我正在運行一個使用WAMP的網站,並安裝了測試郵件服務器工具作為郵件服務器(它只是將郵件保存為.eml文件)。 我嘗試用Lotus Notes和gmail(web界面)打開消息,並且兩者都不解釋HTML,例如,而不是有一個可點擊的鏈接,他們有<a href='localhost'>click here</a>
我有沒有標題出錯?
這是我正在使用的代碼
$to = 'bepusslai@fakeinbox.com';
$from = 'From: tester1@localhost.com';
$subject = 'this is a test';
$message = '<html><head></head><body>Hello. Please follow <a href="http://localhost/proc.php?uid=45ab3">this link</a> to activate your account.'
."r\n".'<a href="http://localhost/proc.php?uid=45ab3"><img src="images/ActivateButton.gif" alt="activate button" />
</body></html>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; utf-8' . "\r\n";
$headers .= 'From: testk1@localhost.com' . "\r\n";
mail($to, $subject, $message, $from, $headers);
順便說一句,我被困在沒有郵件服務器,因為WAMP沒有附帶一個,我在另一個問題上有人推薦測試郵件服務器工具。 我願意使用另一種,因為它似乎不受歡迎。
看看這個例子,它對我有用:
<?
//change this to your email.
$to = "m@maaking.com";
$from = "m2@maaking.com";
$subject = "Hello! This is HTML email";
//begin of HTML message
$message = "<html>
<body bgcolor=\"#DCEEFC\">
<center>
<b>Looool!!! I am reciving HTML email......</b> <br>
<font color=\"red\">Thanks dud!</font> <br>
<a href=\"http://www.test.com/\">* test.com</a>
</center>
<br><br>*** Now you Can send HTML Email <br> Regards<br>MOhammed Ahmed - Palestine
</body>
</html>";
//end of message
// To send the HTML mail we need to set the Content-type header.
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: $from\r\n";
//options to send to cc+bcc
//$headers .= "Cc: [email]maa@p-i-s.cXom[/email]";
//$headers .= "Bcc: [email]email@example.cXom[/email]";
// now lets send the email.
mail($to, $subject, $message, $headers);
echo "Message has been sent....!";
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.