stefanbc
4/4/2013 - 10:34 AM

HTML wp_mail() with attachments

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);
?>