html - wp_mail sending only plain text messages
问题描述
I am sending some emails using wp_mail() function to send some HTML formatted emails. The problem is that the emails all look like basic plain text.
I set my headers to
$headers = array('Content-Type: text/html; charset=UTF-8');
In Windows, I use Fake SMTP server to test. The Content/Type is being recognized as text/html; charset=UTF-8
The problem is that all my emails look like basic plain text. No spacing from divs, no tables, no CSS modifications, nothing. It basically takes the text from the HTML that I wrote and puts it inline. I also tried sending the emails to GMAIL and no luck, it looks the same.
I ran out of options with testing this. What should I change?
解决方案
您是否在 functions.php 中启用了 HTML 标头
add_filter( 'wp_mail', function( $params ) {
$params['headers'] = 'Content-type: text/html';
return $params;
} );
推荐阅读
- python - 我无法理解递归中的返回命令
- spacy - 我的问题是关于“模块'textacy'没有属性'Doc'”
- r - 如何在R中重复机器学习算法设置种子?
- r - 如果不直接使用模型输出计算损失,Tensorflow 急切执行不会获得梯度
- python - 熊猫将列值拆分为单独的列
- wordpress - Wordpress 导航错误未定义属性:WP_Post_Type::$term_id
- javascript - 具有动态内容和行为的导航栏
- javascript - 谷歌标签管理器点击类事件不起作用
- python - tensorflow中的if语句(没有else)
- json - 嵌套数组,使用 JQ 组合多个过滤器