Skip to main content
3 of 3
added 140 characters in body

Here is the sample code for using output buffering. You will be able to access all the variables inside the template which are defined above "include line".

WordPress: Include template in the email.

ob_start();
include(get_stylesheet_directory() . '/assets/email-templates/booking-details-template.php');
$email_content = ob_get_contents();
ob_end_clean();
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail($to_email, "Booking details", $email_content, $headers);