email attachments 403 forbidden
-
Hi!!
I sell documents in my store. After payment, I send a confirmation email using Post SMTP with download links. The user can download without login. Recently we started to test woocommerce_email_attachments dedicated hook for send the documents not as a Link but as email attachtments to the order confirmation email.
We used this hook, from here:
add_filter( 'woocommerce_email_attachments', 'attach_downloadable_files_to_customer_completed_email', 10, 3 ); function attach_downloadable_files_to_customer_completed_email( $attachments, $email_id, $order ) { if( isset( $email_id ) && $email_id === 'customer_completed_order' ){ // Loop through order items foreach( $order->get_items() as $item ) { $product = $item->get_product(); // The product Object if ( $product->is_downloadable() && ( $downloads = $product->get_downloads() ) ) { // Loop through product downloads foreach( $downloads as $download ) { $attachments[] = $download->get_file(); } } } } return $attachments; }
I create a stage website of my site and I tested the hook. The code works, the email get the attachments with the confirmation order email.
When I did the same in my production website, my customers rececived the confirmation email with empty files… the attachments were there but with 0 kb.
Also PHP warnings saying that the URL of the downloable product was blocked, 403 forbidden https://a.cl.ly/8LubPx2O
The file URL is something like: wp-content/upload/woocommerce_upload/2020/02/file.docx
PHP warning:
file_get_contents(https://mywebsite.com/wp-content/uploads/woocommerce_uploads/2xxx/xx/file25022021-bxxg5x.docx): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbiddenpost-smtp plugin
in /home/xxxxxxxxxxxx/public_html/wp-content/plugins/post-smtp/Postman/Postman-Mail/PostmanMessage.php on line 515
thank you in advance for your attention.
In Woocommerce support and Stackoverflow
- The topic ‘email attachments 403 forbidden’ is closed to new replies.