2014-09-22 54 views
0

我試圖使用PHP郵件功能它工作良好,下面的代碼來發送郵件發送郵件:無法從服務器usiong PHP的郵件以HTML格式

<?php 
$to = "[email protected]"; 
$subject = "subject"; 
$password="xxxxx"; 
$message = " 
<html> 
<head> 
<title>HTML email</title> 
</head> 
<body > 
<div style='width:670px;height:450px;padding:50px;background-color:#EFEFEB;'> 
<div style='width:600px;height:450px;background-color:#FFFFFF;color:#105b94;font-size:20px;padding:10px'> 
<img src='http://www.example.com/Images/Index/Logo.png' /> 
<p>Hi,</p> 
<table style='color:#105b94;font-size:20px;'> 
<tr> 
<td><p>Thank you for registering with us.</p></td> 
</tr> 
<tr> 
<td><br>Your password is :$password<br><br>We appreciate your interest. 
</td> 
</tr> 
<tr> 
<td><hr>Contact Us <br>Office :9999999999<br>www.example.com 
</td> 
</tr> 
</table> 
</div> 
</div> 
</body> 
</html> 
"; 

// Always set content-type when sending HTML email 
$headers = "MIME-Version: 1.0" . "\r\n"; 
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 

// More headers 
$headers .= 'From: Support <[email protected]>' . "\r\n"; 


mail($to,$subject,$message,$headers); 
?> 

代碼工作好,如果我刪除www.example。 com從上面的代碼行「辦公室:9999999999
www.example.com
」請幫助我。

+0

如果不這樣做遠程www.example.com – justrohu 2014-09-22 09:56:01

+0

代碼爲我工作很好,你可以請你的郵件服務器的配置 – Prasad 2014-09-22 09:57:34

+0

所以,你要發送的電子郵件直播從它扔了什麼錯誤(可能是假的)電子郵件'example.com'?你有沒有試過一個真正的?這些信息對於所有電子郵件服務都很重要 – 2014-09-22 10:03:40

回答

0

我強烈建議你使用:http://swiftmailer.org/

這包括郵件頭和配置。它管理你不想看到的所有東西。

親切的問候!

+0

這真的是一個很好的建議。誰投下來的?自己做HTML郵件可能很困難,特別是如果你想包含一個非HTML版本的附件,並且你關心支持更多的郵件客戶端而不僅僅是你自己。一票從我身上。 – 2014-09-22 10:21:49

+0

感謝您的誠實。無論是懶惰的用戶誰不想花時間在一個好的解決方案(眨眼)或另一個理想的用戶誰認爲,做所有的東西本身和重新發明輪子是唯一的解決方案:-P – 2014-09-22 20:11:34