Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send an attachment mail using wp_mail mail

Is there anyone to tell me that how to send an attachment email using wp_mail function of wordpress? I am using the following code but its not working

$attachments = array(ABSPATH . '/uploads/abc.png');
wp_mail($email, 'Testing Attachment' , 'This is subscription',$attachments);

Thanks

like image 953
Shah Rukh Avatar asked Oct 30 '12 08:10

Shah Rukh


People also ask

How do I send an attachment by email in WordPress?

From your WordPress dashboard, go to WP Mail SMTP » Settings. On the Settings page, switch to the Email Log tab. Here, you'll find options to Log Email Content and Save Attachments. To follow along with this tutorial, we recommend that you enable both.

What is wp_mail?

What is wp_mail? wp_mail is the function the WordPress uses to send email. This function is essentially a wrapper for the PHPmailer class, a php class that allows sending of email via php script.

How do I send HTML email in WordPress?

You can use WordPress's wp_mail() function to send emails from your WordPress site. However, the default content type is 'text/plain' which does not allow using HTML. If you want to send HTML emails then you will need to set the content type of the email to “text/html” by using the 'wp_mail_content_type' filter.


1 Answers

Try this and let me know then --

$attachments = array(ABSPATH . '/uploads/abc.png');
wp_mail($email, 'Testing Attachment' , 'This is subscription','This is for header',$attachments);

Your attachment is setting as header in this case.

like image 112
swapnesh Avatar answered Nov 15 '22 05:11

swapnesh