wp_mail
does not support rich formatting, so you can’t just embed the image in the body. It does, however, support attachments. If you read about the function, you’ll see it has a parameter for attachments. Try hooking your attachment there instead:
http://codex.wordpress.org/Function_Reference/wp_mail
$attachments
(string or array) (optional) Files to attach: a single filename, an array of filenames, or a newline-delimited string list of multiple filenames. (advanced)
Default: Empty
Edit:
So if you can figure out the attachment id of the image you want to reference, the wp_mail
function will look more like this:
// check if featured image, use it if so
if(has_post_thumbnail()){
$attachment_id = get_post_thumbnail_id();
} else {
// otherwise use first post attachment
$attachments = get_children( array(
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'numberposts' => 1,
);
foreach($attachments as $attachment_id_key => $attachment){
$attachment_id = $attachment_id_key;
}
}
wp_mail(
$data['target'],
$data['post']->post_title,
$content,
'',
wp_get_attachment_url($attachment_id)
);