DOCUMENTATION

  • Emails
  • Files
Search »

Swift Mailer

File Attachments

Once the Swift Mailer is up and running, sending file attachments is a breeze. You can attach files that were included in the form submission OR files that are found on your server. There is no limit to the number of attachments you include, but generally it's a good idea to keep the total size to a minimum.

1. Attaching files from the form submission

To include a file attachment in your emails, edit the appropriate email template and go to the Content tab (where you enter the content for the emails). There, add the following to your template (either text or HTML - it doesn't matter which; just as long as it's in one of them):

You will need to change the file_field1 strings to match the file upload form field name. You can include as many file fields are you want.

If the submission doesn't contain a file for that field, the email just won't include an attachment.

2. Attaching files from your server

Attaching files from your server works in a similar way. For example:

A couple of things to note:

  • Note that the attribute is file not field.
  • The file path is relative to your Form Tools root. So if your Form Tools folder is /formtools, and you have a file that you want to attach that's one folder up, you can put: This assumes that the $g_root_dir value found in your /global/config.php file is correct. We chose to use relative rather than absolute links so that in case you ever change servers, you won't have to update each and every email template.