2013-11-15 32 views
0

好的,好吧,我知道有一百萬個這樣的線程,但我盡我所能去查看它們,找不到能夠真正爲我解決問題的線程。任何幫助非常感謝,因爲根據瀏覽器,它可以隱藏整個事情或以純文本顯示它。發送純文本HTML電子郵件? (PHP)

下面是我使用的是什麼:

$headers = 'From: [email protected]\r\n'; 
$headers .= 'Reply-To: [email protected]\r\n'; 
$headers .= 'MIME-Version: 1.0\r\n'; 
$headers .= 'Content-type: text/html; charset=ISO-8859-1'; 
mail($email,$subject,$content,$headers); 

$內容,並開始使用HTML和body標籤結束後,在體內的開始,在它的一些CSS樣式的標籤。

+0

什麼是$內容變量? –

+1

試試$ headers。=「Content-type:text/html \ r \ n」; –

+0

@MikeBarwick這只是電子郵件的內容。我稍微更新了這篇文章。 –

回答

3

你會想要使用正確的引號。 "\r\n"'\r\n'是兩個完全不同的東西。

如果你生鏽,請閱讀PHP handles strings

+0

啊,真可愛。我現在就測試一下......我確實知道PHP如何處理字符串,但是我從來沒有真正使用過\ r和\ n,只是假定它是由瀏覽器處理的。謝謝! –

+0

這就是我所需要的,謝謝。 –

0
Use this 




    // Always set content-type when sending HTML email 
    $headers = "MIME-Version: 1.0" . "\r\n"; 
    $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; 
    // More headers 
    $headers .= 'From: <[email protected]>' . "\r\n"; 
    mail($email,$subject,$content,$headers);