Skip to content

Instantly share code, notes, and snippets.

@stefanbc
Created April 4, 2013 10:34
Show Gist options
  • Save stefanbc/5309395 to your computer and use it in GitHub Desktop.
Save stefanbc/5309395 to your computer and use it in GitHub Desktop.
HTML wp_mail() with attachments
<?php
$headers = "MIME-Version: 1.0\r\n";
$headers .= 'From: ' . get_bloginfo('admin_email') . "\r\n";
$headers .= "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n";
$receiver = get_user_by('id', $receiver_id);
$giver = get_user_by('id', $giver_id);
$to = $receiver->user_email;
$subject = 'Subject';
$message = 'From: <a href="http://example.com/' . $giver->display_name . '">' . $giver->display_name . "</a><br>";
$message .= 'Message!';
$atach = array(WP_CONTENT_DIR . '/PATH_TO_FILE');
wp_mail($to, $subject, $message, $headers, $atach);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment