I have an HTML invoice that I want to send.
I use the following function to replace some things in the HTML
foreach($variables as $key => $value){
$template = str_replace('{{ '.$key.' }}', $value, $template);
}
After that I send the mail:
$to = get_option('admin_email');
$subject = "Someone reserved from ".get_bloginfo('name');
$headers = 'From: '. $email . "\r\n" . 'Reply-To: ' . $email . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html';
add_filter( 'wp_mail_content_type', 'set_html_content_type' );
function set_html_content_type() {
return 'text/html';
}
wp_mail($to, $subject, strip_tags($template), $headers);
The mail I get is like this:
Invoice article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary { display: block; } audio, canvas, video { display: inline-block; } audio:not([controls]) { display: none; height: 0; } [hidden], template { display: none; } html { font-family: sans-serif; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; } body { margin: 0; } a { background: transparent; } a:focus { outline: thin dotted; } a:active, a:hover { outline: 0; } h1 { margin: 0.67em 0; font-size: 2em ...
(and the rest of the CSS), and then some HTML text without the HTML tags. So it does recognize HTML because it doesn't show <p>
and other tags but it doesn't use the CSS.