Adding Downloadable Woocommerce
products to email as Attachments

When you’re selling virtual downloadable products through Woocommerce, its always important to cover all details. Simplifying as much as possible will in turn boost your sales and customer reputation tremendously.

One of the many things you can do to ensure customers might see their download more obviously, is to place downloadable attachments inside emails sent through your Woocommerce templates. 

Paste the code underneath in your functions.php to activate it.


  1. Great share that is what i need. I have add the code and try it out works perfect to sent the files as attachment. There is only one problem with stamping the PDFs through an PDF Stamper plugin, it does not work. I must now figure out this problem, did you have an idea?

  2. Hi,

    Thank you for this code its great. Just one question, one of my downloads is over 5MB in size. I am finding this email is not being sent when attached. Do you know how to check if the size is what is causing the email to fail? Thank You.

    1. Hi Jill,

      whether or not its the size causing the email to fail is a bit hard to say without looking into it throughout. However, you could make an easy test by uploading different size downloadable products, see whether or not they go through, and if it is in fact the size which complicates.

      Woocommerce’s (and WordPress) email delivery has a different array of possibilities in which it can fail. Being on shared hosting for instance, with shared IP adresses, can backfire on email services accepting the email delivery.

      If some of those same IP adresses spam, theres a chance it’ll end up hurting your own business in the long run.

      A good idea would be to get a unique IP address for your server and/or try out a third party SMTP provider.

      SMTP is what WordPress / Woocommerce sends emails through. Having a third party SMTP provider will give the benefit of having all your emails relayed through their trusted network. They verify the ownership of your website, in turn making email providers trust your emails, and will send you a flow of success, failure and reliability reports.

      There’s a wide range of providers you can choose if you go down that path. Amazon SES is quite cheap with $1 per 10,000 emails per month, mailgun lets you send 10,000 emails free per month, etc.. There are lots of good, trusted, ones.

      Let me know what you came up with!

  3. Thanks for sharing your codes. I have placed the codes in my functions.php file but I can’t see any link to attach a file.
    Could you please describe how to implement it after adding the codes in the functions.php file?

    1. Hi Walex,

      The code is meant to be copy pasted into your functions.php – the rest is taken care of by Woocommerce itself.

      To add a downloadable file to a product in Woocommerce in the WordPress admin panel:

      1: Navigate to your product page
      2: Click edit on the product you’d like to be downloadable.
      3: Click the option downloadable (scroll down to product data)

      In the general section of the product data, you’ll then be able to upload a file to your product – which will also be seen in the emails sent out to your product purchasers.

      If you have further problems let me know and we can sort it out together.

  4. Hello, I have placed the codes in my functions.php file but this script is not working for me. My downloadable product don’t attach to email. You can see

Leave a Reply to Hakan Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.