使用wp_mail()发送HTML电子邮件时CSS不起作用

I am trying to send a HTML mail with the Wordpress function wp_mail() like this:

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 .'>' . "
";
wp_mail( $_POST['email'], $_POST['subject'], $_POST['mail_text'], $headers);
remove_filter( 'wp_mail_content_type', 'set_html_content_type' );

All HTML tags like <strong>, <li>, <p> etc. come with HTML format. But when I try to change the color using HTML or CSS like <li style="color:red">Word</li> or <li color="red">Word</li> it won't work and appears as blank text.

What am I doing wrong?

The text/message you send is in $_POST['mail_text'] coming from a textarea, right? Did you echo out the content of $_POST['mail_text']? Is it ok before sending?

Try single quotes:

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

and check if somewhere a script calls strip_tags to remove html tags.

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

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

user this headers in email for sending html