Skip to content

Instantly share code, notes, and snippets.

@Apina
Created December 16, 2013 09:04
Show Gist options
  • Save Apina/7984216 to your computer and use it in GitHub Desktop.
Save Apina/7984216 to your computer and use it in GitHub Desktop.
Send an attachment with an EE email - change the attachment location. Add this to the custom files add on (custom_functions.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";
//Debug
// echo '<br/><br/><br/><br/>';
// echo '<p>$headers = '.$headers.'</p>';
// echo '<p>$send_to = '.$send_to.'</p>';
// echo '<p>$email_subject = '.$email_subject.'</p>';
// echo '<p>$email_body = '.$email_body.'</p>';
// echo '<p>'.$email_body.'</p>';
// echo '<br/><br/><br/><br/>';
//CHANGE THIS!!
$attachments = array( WP_CONTENT_DIR . '/uploads/2013/12/hat.png' );
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, $attachments);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment