2014-02-27 50 views
3

我想在我的電子郵件內容中以粗體郵寄一些文字。我用下面的代碼如何在PHP郵件()中使文本變爲粗體?

$to = '[email protected]'; 
    $headers = 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-Type: text/html; charset=UTF-8' . "\r\n"; 
     $from = $param['email']; // this is the sender's Email address 
    $headers = "From:" . $from; 

    $name = $param['name']; 

    $subject = "Test"; 

    $message = "message.\n\n" 
       ."<b>Name:</b> ".$name . "\n\n" 
       ."Adress: \n" 
       .$param['address'] . "\n" 
       .$param['zip'] . ", " 
       .$param['postal_area'] . "\n\n" 
       ."E-post: ".$param['email'] . "\n\n\n" 

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

我用<strong>也代替<b>標籤,但沒有任何工程。 我收到以下格式的郵件:

<b>Namn:</b> some name 

Adress: 
Borås, Sweden 
4837, Boras 

E-post: [email protected] 

回答

12

您正在覆蓋頭變量。你需要追加到它。

$headers .= "From:" . $from; //You forgot to concatenate here... 
//  ---^ //Add the . 
2

嘗試在跨度設置字體粗細屬性:

$message = "E-post: <span style='font-weight:strong;'>".$param['email']."</span>"; 

還能看到其他的答覆,要覆蓋頭部所以不讀消息HTML。

相關問題