• Emails
Search »

Content Tab

Emails » Content Tab
Emails » Content Tab

Now for the fun stuff! The content tab is where you enter the content of your email. There are two fields in the page: HTML template and Text template.

Email formats

The three most common ways to send emails are: HTML, text and "multipart". Multipart emails are just HTML and text versions bundled together and sent in the same email; the recipient's email client (e.g. Windows Outlook, Gmail, Eudora etc) then chooses which one to display.

Form Tools does the job of figuring out how to send the email based on what you enter in these two fields. If you enter just HTML, it will send the email in HTML format only; if you enter text, it'll send it in text format, and both? You guessed it: it'll send it in multipart. Not exactly brain surgery.

The email content / Smarty!

To save you the effort of having to build your emails by hand, we've created a number of pre-constructed emails (or "email patterns") found in the "Examples" dropdowns for each of the two content fields. Try selecting one and see how it automatically fills in the email content for that section.

The email content is generated with a language called "Smarty". Smarty is a templating language that allows you to embed logic and variables into the templates. This is extremely powerful. You can use this language to do pretty much anything you need. With Form Tools 1.x, you had to enter PHP to create any logic (such as omitting empty fields) and this caused a lot of problems. Smarty is a far simpler approach.

A very, very short introduction to Smarty

By and large, you won't need to know anything about Smarty. You can just pick one of the example email patterns, test it out and you're done! But here's a little more information if you're curious.

A placeholder is a sequence of characters like {$ANSWER_my_email_field}. When the email is sent, it is converted to whatever special meaning it assigned to it. For a list of all available placeholders for your form, see the Reference tab.
Smarty also lets you embed logic (like if-else tests). To use the placeholder we just mentioned, we could add something like this: That will then add that derisive comment to the email IF the email sender if

"All Fields" vs. "Smarty Loop" patterns

In the example dropdowns, you'll see the email patterns arranged into four groups: "All fields", "Smarty Loop", "Notification Only" and "Programming Example". (If you're a non-programmer, you won't be interested in the last one: just ignore it. Pretend it's not there).

The Notification Only examples are very straightforward: just a "thanks" message and a line with the time the submission was made. Simple.

The "All Fields" and "Smarty Loop" patterns are more complicated. Both generate the same email content, but they do it in different ways. The "All Fields" patterns generates the entire HTML or text for all variables in your form, and directly reference the variables through their placeholders: {$QUESTION_name} and {$ANSWER_name}. This generates an email template that's pretty easy to follow, even at a glance. The placeholders are fairly simple to understand: {$QUESTION_name} would be replaced with the label for the name" form field, and the response entered by the user in your form would replace the {$ANSWER_name} placeholder.

The Smarty Loop patterns are more complicated, but also more powerful. Instead of referencing each individual placeholder, it generates the email content by looping over each field being passed to it, generating the content line by line. The benefits to this approach are:

  • You can access a lot of "meta" information about each field, including the field type, size, the form field name, database column - and more.
  • It allows you to map this particular email template to a particular View (via the "Limit email content to fields in View" setting on the first Configuration tab). This restricts the field list that's sent to the Smarty Loop to only those fields assigned to the View.
  • The additional benefit of assigning it to a particular View is that any time you change the list of form fields that should appear in the View, the email is automatically updated. By using the previous "All fields" option where you'd manually doctored the email content to only show the appropriate list, you would need to re-edit the contents - which can be easy to forget.

The drawback to using the Smarty Loop option that if you're going to edit the email contents, it can be more complicated.