Here is the sample code for using output buffering. > *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);