Attach file to outgoing emails

This tutorial will show how to attach files to emails that your PrestaShop is sending. We will use conseqs module to achieve this without the need for custom overrides.

Note that this tutorial works for PrestaShop 1.7 and thirtybees platforms only. Unfortunately, PrestaShop 1.6 doesn't have that is necessary.


We want to attach pdf file with Terms and Conditions to all Order Confirmation emails. We want to send different files for regular customers and B2B customers. 

Step 1: Prepare files

Before we start creating conseqs rules, we need to do some preparation first. We need to upload Terms of Conditions files them to server server. These files have be named them like this. 



Important part is customer / b2b suffix. This must match names of customer groups in your PrestaShop.

Step 2: create new rule

We will start by creating new Rule from scratch. To do this, go to your Rule overview, and click on New Rule. Go to Rules overview page and click on CREATE RULE button. 

create new rule

Step 3: choose trigger

Because we want to attach file to sent email, we need to choose some trigger that allows us to do so. There is only one: Before emailThis trigger will be executed before the email is sent. It allows us to use email specific actions to adjust email parameters. We can, for example, change email subject, add email to BCC list, or attach file. That's exactly what we want

Step 4: conditions

We don't want to attach these files to all outgoing emails, only to Order Confirmation email. So let's create condition for this. In Conditions steps, click on New condition. Type of email is decided by Email template, so we will use this variable and match it to constant string - order_conf

Step 5: attach file

We are almost finished. We now have rule to detect when Order Confirmation email is about to be sent from PrestaShop. Now all we need to do is attach our file - simply select Email: attach file action from list of available actions:

Now comes the tricky part. This action needs path to file to attach. But this path is different for every customer group. There are three ways to set action parameters:

  • Constant value - we could provide static text. We can't use this one, obviously
  • Bind value - we can use one of the variables available. There is variable named Group Name, but that itself isn't enough to point to the file on server
  • Interpolate values - this is the combination of above. We can enter static text, and substitute placeholders with variables values. This is what we will use

So we will choose Interpolate values method, and enter full path to our files on server. When we get to the customer group part, enter character @

This will open popup window to insert variables. Find Group: Name variable, and insert it into the text.

The result should look like this

Conseqs module will substitute customer group name (customer or b2b) into the filepath action parameter, and correct file will be attached to the email.

You should now test the rule. When you create test order, Order Confirmation email should contain correct file. If not, please look into Logs section in conseqs module to find source of the problem.

Related products