Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active December 18, 2018 14:55
Show Gist options
  • Select an option

  • Save joshfeck/7532398 to your computer and use it in GitHub Desktop.

Select an option

Save joshfeck/7532398 to your computer and use it in GitHub Desktop.
use wp_mail_content_type filter instead of hard coding the content type in the email function. Event Espresso 3.1.35
<?php
function event_espresso_send_email($params) {
global $org_options;
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
extract($params);
//Define email headers
$headers = "";
if ($org_options['email_fancy_headers']=='Y') {
$headers .= "From: " . $org_options['organization'] . " <" . $org_options['contact_email'] . ">\r\n";
$headers .= "Reply-To: " . $org_options['organization'] . " <" . $org_options['contact_email'] . ">\r\n";
} else {
$headers .= "From: " . $org_options['contact_email'] . "\r\n";
$headers .= "Reply-To: " . $org_options['contact_email'] . "\r\n";
}
//$headers .= "Content-Type: text/html; charset=utf-8\r\n";
if (!function_exists('ee_set_html_content_type')) {
function ee_set_html_content_type() {
return 'text/html';
}
}
add_filter( 'wp_mail_content_type', 'ee_set_html_content_type' );
return wp_mail($send_to, stripslashes_deep(html_entity_decode($email_subject, ENT_QUOTES, "UTF-8")), stripslashes_deep(html_entity_decode(wpautop($email_body), ENT_QUOTES, "UTF-8")), $headers);
remove_filter( 'wp_mail_content_type', 'ee_set_html_content_type' );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment