gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 17:33:26 25 4
gpt4 key购买 nike

我正在尝试使用 Wordpress 函数 wp_mail() 发送 HTML 邮件,如下所示:

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>它不会工作并显示为空白文本。

我做错了什么?

最佳答案

您发送的文本/消息在 $_POST['mail_text'] 中来自文本区域,对吗?您是否回显了 $_POST['mail_text'] 的内容?发送前可以吗?

试试单引号:

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

并检查脚本是否在某处调用 strip_tags 来删除 html 标签。

关于php - 使用 wp_mail() 发送 HTML 电子邮件时,CSS 将不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30134743/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com