2015-05-09 101 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