2015-05-09 147 views
1

我試圖發送HTML郵件與WordPress的功能wp_mail()這樣的:CSS將無法正常工作

add_filter('wp_mail_content_type', function($content_type) { return 'text/html'; }); 
$headers = 'From: '. $current_user->user_firstname . ' ' . $current_user->user_lastname .' <'. $current_user->user_email .'>' . "\r\n"; 
wp_mail($_POST['email'], $_POST['subject'], $_POST['mail_text'], $headers); 
remove_filter('wp_mail_content_type', 'set_html_content_type'); 

所有的HTML標籤,如<strong><li><p>等與HTML格式。但是當我嘗試使用HTML或CSS(如<li style="color:red">Word</li><li color="red">Word</li>)更改顏色時,它不起作用,並顯示爲空白文本。

我在做什麼錯?

回答

0

您發送的文本/消息是$_POST['mail_text']來自textarea,對吧? 您是否迴應$_POST['mail_text']的內容?發送之前可以嗎?

嘗試單引號:

<li style='color:#f90'>Hello World</li> 

,並檢查是否某處的腳本調用strip_tags刪除HTML標籤。

0
$headers = "MIME-Version: 1.0" . "\n"; 
    $headers .= "Content-type: text/html; charset=iso-8859-1" . "\n"; 
    $headers .= "X-Priority: 1 (Higuest)\n"; 
    $headers .= "X-MSMail-Priority: High\n"; 
    $headers .= "Importance: High\n"; 

    $headers .= "From: Approprice <".$mailfrom.">" . "\n"; 
    $headers .= "Return-Path: Approprice <".$mailfrom.">" . "\n"; 
    $headers .= "Reply-To: Approprice <".$mailfrom.">"; 

用戶這個標題的電子郵件發送HTML