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
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? 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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With