2012-09-06 40 views
1

出於某種原因,我的PHP mail()函數不發送HTML,而不是<a href="mysite">link</a>PHP的郵件沒有發送HTML內容

它顯示只是顯示link爲純文本。

任何想法?

這是我使用的頭:

$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; 

// Additional headers 
$headers .= 'From: My Automated Message <[email protected]>' . "\r\n"; 

並援引如下:

try { 
    if (@mail($to_email, $subject, $message, $headers)){ 
     echo "<span style=\"color:#0D0; font:10pt Tahoma;font-weight:bold;\">{$SENT_MESSAGE}</span><br><br>"; 
     return true; 
    } else { 
     $tmp=error_get_last(); 
     throw new Exception($tmp['message']); 
    } 
} catch (Exception $e) { 
    echo "<span style=\"color:red; font:10pt Tahoma;font-weight:bold;\">Error: ".$e->getMessage()."</span><br><br>"; 
} 

我也試圖發送郵件沒有標題,但隨後又給出了鏈接以純文本像這樣:<a href="mysite">link</a>

回答

1

試試這個標題

$headers = 'From: Name<[email protected]>' . "\r\n" . 
     'Content-Type: text/html; charset=UTF-8' . "\r\n" . 
     'MIME-Version: 1.0' . "\r\n" . 
     'Content-Transfer-Encoding: base64' . "\r\n" . 
     'X-Mailer: PHP/' . phpversion(); 
+0

大聲笑,這是它得到的?我:'N(???? * ????? KJب?? ^jǜ'$? ' – Anonymous

+0

不,我只收到並閱讀我的電子郵件 – Anonymous

+0

然後試試這個,希望這會幫助你'$ headers ='發件人:姓名<[email protected]>'。 「\ r \ n」。 'Content-Type:text/html; charset = UTF-8'。 「\ r \ n」。 'MIME-Version:1.0'。 「\ r \ n」。 'X-Mailer:PHP /'。 phpversion();' –

0

入住這

$from='[email protected]';  
$headers =''; 
$headers .= 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
$headers .= 'From: '.$from.' '. "\r\n"; 

mail($to_email, $subject, $message, $headers);