2014-01-20 34 views
0

我發送電子郵件的敵人我的用戶,他們登記後,在我的網站如下所示:如何在php中使用style內部的一個txt變量?

 -------------------------------- 
     Hello world 
     -------------------------------- 
     gogogo 
     http://example.com/ ailesine katıldığınız için teşekkürler. 

     Giriş Bilgileriniz: 

     Kullanıcı Adı: xxxxxx 
     Şifre:   xxxxxx 

     Buradan giriş yapın: http://example.com/?page=login.php 

     Saygılar 
     example.com Yönetimi. 

     -------------------------------- 
     Sosyal ağlarda takipte kalın: 
     Google : https://plus.google.com/+example 
     Twitter: https://twitter.com/example 
     Facebook: https://www.facebook.com/example 
     Youtube: http://www.youtube.com/user/example 
     -------------------------------- 

我想要的顏色添加到該電子郵件,我想使第一部分爲紅色,我想使鏈接在底部不可點擊。

我嘗試使用一些HTML標記和樣式屬性顏色的TXT,但它僅發送如下:

 <span style="color:red;">-------------------------------- 
     Hello world 
     --------------------------------</span> 
     gogogo 
     http://example.com/ ailesine katıldığınız için teşekkürler. 

     Giriş Bilgileriniz: 

     Kullanıcı Adı: xxxxxx 
     Şifre:   xxxxxx 

     Buradan giriş yapın: http://example.com/?page=login.php 

     Saygılar 
     example.com Yönetimi. 

     -------------------------------- 
     Sosyal ağlarda takipte kalın: 
     Google : https://plus.google.com/+example 
     Twitter: https://twitter.com/example 
     Facebook: https://www.facebook.com/example 
     Youtube: http://www.youtube.com/user/example 
     -------------------------------- 

注意我的用戶PHP函數來發送電子郵件和EAMIL信息保存在一個PHP可變電話$messege

如何爲文本着色並使鏈接無法點擊?

+0

套頭,它不是純文本,但HTML內容。如果使用某個庫來發送電子郵件,他們對純電子郵件和HTML電子郵件內容有單獨的方法 – Justinas

回答

1

我的建議是在HTML格式

$message = "<html> 
    <body style='background-color:grey> 
    <center> 
     <b> HTML email</b> <br> 
     your text and adesign 
    </center> 

    </body> 
</html>"; 

完全使用$message然後

$headers = "From: $from\r\n"; 
    $headers .= "Content-type: text/html\r\n"; /*<= this is very important */ 

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

下面是關於它的良好的閱讀:css tricks

+0

我寧願使用** [heredoc](http://www.php.net/manual/en/language.types。 string.php#language.types.string.syntax.heredoc)** –

+0

@HashemQolami:嗯....從來沒有在它的工作,所以不能建議...我找到'html'方式爲自己容易:) – NoobEditor

相關問題