I'm using wp mailwp_mail()
to send an htmlHTML email. But there's quite a lot of htmlHTML code in the email, so rather than including all the code in my wp mailwp_mail()
function, is it possible to have the code in a separate template and just include this template in the function? Here is what I have:
<?php if ( isset( $_POST['submitted'] )) {
add_filter('wp_mail_content_type',create_function('', 'return "text/html"; '));
$emailTo = '[email protected]' ;
$subject = 'This is the subject';
$body = get_template_part( 'includes/my_email_template' );
$headers = 'From: My Name' . "\r\n";
wp_mail($emailTo, $subject, $body, $headers);
}?>
I'd like to be able to put all of my htmlHTML code in 'my_email_template' but when I try this, no email is sent. Am I including the template incorrectly? Thanks in advance for any answers.