I have a custom WooCommerce email that needs to send to the third party.
In this email, I have to add an attachment. I tried with wc_mail() but the attachment not attached.
Here is how it look likes:
$attachment = array();
ob_start();
include('some-html-email-content.php');
$message = ob_get_clean();
$attachment[] = get_template_directory() . '/some.pdf';
wc_mail('[email protected]', 'some subject ', $message, "Content-Type: text/html\r\n", $attachment);
I can receive the email without any problem, only the attachment is not there. What did I done wrong?
I can't use woocommerce_email_attachments filter hook, because this mail isn't attached to any regular woocommerce mail (new order, process, new user etc....).
I also tried with wp_mail() still I cannot make it through.
$attachment = array( WP_PLUGIN_DIR . '/my-plugin/uploads/sample_photo_01.jpg' );
Attachments should always use the absolute filesystem path. Change location/name of file based on where the attachment is located.
Sources: http://codex.wordpress.org/Function_Reference/wp_mail http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_mail_content_type
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