Attachments should always use the absolute filesystem path.
Also to change the Content-Type
of the email you should use the wp_mail_content_type
filter.
<?php
function my_custom_email() {
$to = '[email protected]';
$subject="WordPress wp_mail";
$message="
<html>
<body>
<table rules="all" style="border-color: #666;" cellpadding="10">
<tr>Hello WordPress</tr>
</table>
</body>
</html>
";
$attachments = array( WP_PLUGIN_DIR . '/my-plugin/uploads/sample_photo_01.jpg' );
$headers[] = 'From: '.get_option( 'blogname' ).' <'.get_option( 'admin_email' ).'>';
add_filter( 'wp_mail_content_type', 'my_custom_email_content_type' );
return wp_mail( $to, $subject, $message, $headers, $attachments );
}
function my_custom_email_content_type() {
return 'text/html';
}
I have placed the entire code in a function so that the wp_mail_content_type
filter applies only to this email.
Sources:
http://codex.wordpress.org/Function_Reference/wp_mail
http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_mail_content_type