18910140161

PHP-HTML代码将以电子邮件形式发送,而不是呈现视图WordPress-Stack溢出

顺晟科技

2022-10-19 12:58:26

12

我在每次更新后都添加了发送电子邮件的操作,在电子邮件日志中我可以看到正确的视图正在发送,但我不明白为什么gmail显示的是模板的html代码而不是呈现的视图。

functions.php

$email_body = file_get_contents(get_stylesheet_directory(). '/email/template2.php');    
$headers = 'From: Test <support@test.com>';
$headers .= "Content-Type: text/html";
$title = wp_strip_all_tags( get_the_title( $post->ID ) );
     if ( get_post_type( $post->ID ) === 'property' ) {
            wp_mail( $emails, $title, $email_body, $headers );
        }

HTML模板:

$email_body = file_get_contents(get_stylesheet_directory(). '/email/template2.php');    
$headers = 'From: Test <support@test.com>';
$headers .= "Content-Type: text/html";
$title = wp_strip_all_tags( get_the_title( $post->ID ) );
     if ( get_post_type( $post->ID ) === 'property' ) {
            wp_mail( $emails, $title, $email_body, $headers );
        }

在后SMTP日志中,我可以检查正确的视图正在生成,但在gmail收件箱中,电子邮件正文中有HTML代码,有人能帮忙吗?


顺晟科技:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航