Php 使用wp_邮件发送的电子邮件格式
我想以html表格的形式发送格式化电子邮件。我正在使用wp_邮件发送电子邮件Php 使用wp_邮件发送的电子邮件格式,php,wordpress,html-email,Php,Wordpress,Html Email,我想以html表格的形式发送格式化电子邮件。我正在使用wp_邮件发送电子邮件 我想知道格式化是如何工作的?现在我没有对内容类型进行任何更改。如果电子邮件编辑器不使用html支持,只使用纯文本,那么使用标记发送电子邮件会有什么影响。我希望这两种情况下的电子邮件格式都正确 您可以在wordpress中使用添加过滤器()进行html格式设置 像这样: add_filter('wp_mail_content_type',create_function('', 'return "text/html";')
我想知道格式化是如何工作的?现在我没有对内容类型进行任何更改。如果电子邮件编辑器不使用html支持,只使用纯文本,那么使用标记发送电子邮件会有什么影响。我希望这两种情况下的电子邮件格式都正确 您可以在wordpress中使用
添加过滤器()
进行html格式设置
像这样:
add_filter('wp_mail_content_type',create_function('', 'return "text/html";'));
wp_mail( $to, $subject, $message, $headers );
这可能会帮助您……您可以在
wp\u mail
功能之前添加过滤器,然后将其删除
add_filter( 'wp_mail_content_type', 'set_html_content_type' );
@wp_mail( 'email', 'subject', 'message');
remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
您需要添加在上述代码中使用的过滤器中调用的以下函数
function set_html_content_type() {
return 'text/html';
}
有关此筛选器的更多信息,请参阅codex:您可以添加模板电子邮件,例如: 1.包括你的模板
include_once(get_template_directory().'/emails/demo.php');
2.将函数添加到文件模板
function email_template($id){
....
return $body;
}
*id是你的模板电子邮件的可变输入,你可以放任何东西
3.将电子邮件模板()的输出放入电子邮件中
horra您发送的模板电子邮件没有任何插件和外部代码
这是我的英语
$body= email_template($varibles);
wp_mail('example@site.com','subject',$body);