I have a webform where a user can upload a file to the webform. I would like to be able to email the file via Rules to a sysadmin. I know I can send it from Webform directly, but I am also needing to attached a FillPDF file that can only be sent via Rules.

2 Answers 2


Yes it is possible to use the Rules module for sending an eMail with an attached file. To do so, make sure you have the Mail System and Mime Mail modules installed/enabled.

The Rules Event you want to use is probably when the Webform is submitted.

Then create a rule with a Rules Action to Send an HTML email. Specify the eMail body content, and then the email's attachment(s). If you have multiple attachments, make sure to specify 1 file (only) per line. The tricky part you probably run into is to correctly specify the filename of the attached files. The correct way to do so is like so:


That is also what is suggested in Comment # 25 of support issue (not bug ...) #1431572.

In your case, make sure that this path refers to the webform that is submitted and contains the attached file. Using the "Webform Rules" module, you should be able to have Rules react on an event like "Webform submitted". And if you then add a Rules Condition like "entity has field" (with the field corresponding to your attached file), you should be able to "do something" with that filename of your attachement. E.g. trigger another Rules Component that uses as a parm ... the path of your attached file. With that, your Rules Component should then take care of sending the actual eMail, with the correct value of the filename for the file to be attached.

Use Rules debugging

This question is pretty tough to answer with the limited info you provided (and without access to "your" site). Therefor I suggest you also consider 2 variations of Rules debugging, which are:

  • Within the rules settings, experiment a bit with the debugging facilities that come with the rules module. At least have a look at the "Rules Evaluation Log" (to check that the Rules logic being executed, actually matches what you expect that logic to be).
  • (Temporary) enable the Devel module, so that you can (temorary) add a Rules Action like "Display a value" (in your case of the entire node/webform that's used to submit that attached file).

For way more details about these 2 variations, refer to Rules debugging, as explained in the answer to "How can I display the value of a variable inside a condition?".

  • Thank you Pierre but that is where I run into a problem. Since the user is the one uploading the file I do not know the name of the file. The goal is to send the file that the user updates when completing the form (ie. the contents of the file field) via Rules to an admin.
    – penone
    Commented Feb 26, 2016 at 16:38
  • Hm, I don't give up yet ... I might be able to enhance my answer if you first better explain how you implemented your "... upload a file to the webform ...". Is that via some field you added to your webform? If so what's the filetype. And also should they add (upload) such file before they submitted the form? And is it optional (as per our "can"). If it's something else, please explain how you implemented it then instead. Commented Feb 26, 2016 at 17:15
  • I am using the Webform multiple file module. I did find a patch that let's me rename the files. What I have done is had the rename to the submission serial number and then "attachment" (ie.1234_attachment.jpg). Now am trying to figure out how to mail that attachment using Rules.
    – penone
    Commented Feb 26, 2016 at 19:22
  • 1
    Can you explain a bit more the [node:field-file-attachments:file:path]? Am I to place that as is or do I need to change the values to reflect my specific need.
    – penone
    Commented Feb 26, 2016 at 20:10

The video tutorial Send email with attachments via Rules explains how to use Rules and modules Mail System & Mime Mail for sending emails with attachments

I tried it before and it works.

  • Thanks. Saw that video in my quest but my issue lies where I do not know what the file name will be. The goal is to email the file that the user uploads when completing the form (ie. the contents of the File field).
    – penone
    Commented Feb 26, 2016 at 16:44
  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – mpdonadio
    Commented Feb 27, 2016 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.