2

I am attempting to create HTML emails in woocommerce. I currently only have the plain text email option available. I have added the following to functions.php on my theme:

function wps_set_content_type(){
  return "text/html";
}
add_filter( 'wp_mail_content_type','wps_set_content_type' );

As well I have installed the following php modules php-gd, php-xml and php-xmlrpc. I have restarted apache after installation and verified that all modules are available.

The odd thing is that when I check the options locally, I have the HTML option. When I check on the live server there is only the plain text option. Locally I am running PHP 5.6.14-1+deb.sury.org~trusty+1 (cli) on the live server I am running PHP 7.0.20 (cli) (built: Jun 10 2017 06:34:07) ( NTS ). Surely PHP7 can handle this right?

Does anyone have a clue on what else I could try?

1
  • Then something else has gone wrong. The PHP DOM extension, php-xml, should be enough provided it's installed and enabled correctly. In php -a try echo class_exists( 'DOMDocument' ); and you should see "1" printed.
    – Rup
    Apr 27, 2021 at 15:42

1 Answer 1

1

I think you missing function argument. just try it.

add_filter('wp_mail_content_type','set_content_type');
    function set_content_type($content_type){
      return 'text/html';
    }
2
  • 1
    I have tried this, but it is still not working.
    – codacopia
    Aug 1, 2017 at 19:13
  • 1
    It didn't work for me either
    – Laurent
    Mar 4, 2019 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.