Last updated February 2, 2012. Created by gpk on November 10, 2011.
Edited by david.houlder. Log in to edit this page.

There are 2 ways of customising the emails that you can get webform to send when a user submits a form:

  • use the built-in email templating interface
  • use a webform email template in your theme directory

Using the built-in email templating interface

This is the easiest way of customising the emails that webform sends.

  1. Go to the Webform --> E-mails screen for the webform in question
  2. Either use the Edit link for an existing email recipient, or Add a new recipient. This should get you to the Edit e-mail settings screen.
  3. Scroll down to the E-mail template settings. Change Default template to Custom template. Modify the composition of the email, editing the text as desired and using any of the Tokens listed under "Token values" to add in any of the variable data you need. %email_values is the simplest way of getting all the values entered by the user into the email. You can easily include or exclude the value of a specific component by checking or unchecking the relevant component under "Included e-mail values".
  4. Click Save e-mail settings at the bottom of the page and that's basically it.

Using a webform email template

For greater control over the content of the email you can use a template in your site's theme directory.

  1. Copy the default webform-mail.tpl.php template (usually found in sites/all/modules/webform/templates/) to your site's theme directory.
  2. Clear the theme registry (e.g. by clearing caches on the Settings/Performance screen, or using devel module) so that the new template is picked up (you need to do this every time you add or remove a template, but not when you modify an existing template).
  3. Edit the template to suit your needs. There are instructions and suggestions in THEMING.txt and in the supplied webform-mail.tpl.php. Note that that putting
    in the template file is a very handy way of finding out some of the available variables.
  4. Note that the output from webform-mail.tpl.php is subject to %-token substitution. If your template produces output from user-submitted data in $submission, it may be possible for users to inject %-token strings into form fields that might reveal data you would rather keep hidden (e.g. %value[some_form_field]). To avoid this, include the %email_values token in your template, and put your email message theme code in webform-submission.tpl.php instead like this:
    if (isset($email)) {
    // Code to generate email message
    } else {
    // behave like default webform-submission.tpl.php
    print drupal_render($renderable);
  5. You can have a global template for all webforms, and/or have different templates for particular webforms, as described in the instructions.
  6. In order to use the template you have created, you must set the webform's E-mail template setting to Default on the Edit e-mail settings screen.

Technical note about using email template files: when you select the Default template on the Edit e-mail settings screen the textarea underneath shows the currently active webform mail template (either the default supplied with webform, or one from your theme folder, or the relevant webform-mail-[nid].tpl.php from your theme folder) after PHP processing but before token substitution. Any changes you make to the template file will show up immediately when you refresh the Edit e-mail settings screen, assuming that your changes modify the result of running your template through PHP. (This isn't always the case - for example, you won't be able to see the result of code that only runs for Anonymous users.)

Looking for support? Visit the forums, or join #drupal-support in IRC.


I am currently using Webforms as a block for a specific Content Type.

What i am trying to achieve is to print the Content Type Title either in the form itself or the email template.

Any ideas or directions would be greatly appreciated?

I have exactly the same issue - did you find an answer to this? (I've searched but not found anything...)

I believe %post[entity_type] will do the trick, or at least give you the machine name which you can alter.

to see all the post available data:


in your webform template file

How do I get this :

Submitted values are:

To out put each value on a separate line in stead of all jumbled together?

For those struggling with the customization of the emails, I provide an example snippet of my template file.

I copied webform-mail.tpl.php to my template folder, renamed it to webform-mail-135.tpl.php as the webform is node/135.

Then I changed the contents to provide the values I need, for example I have a "customer number" text-field with id 54. To print the entered value, I use

print ('<b>Customer Number:</b> '.$submission->data[54][0]);

My site uses profile2 with a profile with machine name "user_main". That profile contains an address. This address is available as a token, so I include it into my email with

print ('<b>Address: </b>[submission:user:profile-user-main:field_postal_address]');

One field (id 51) in my webform is a comment (text area), which I include in the mail only if a value was entered:

if ( !empty($submission->data[51][0])) {
print (

Finally the most advanced function is a table of all entries of number fields, but only if the value was changed from the default zero.
I check if the type of the field is "number" with $node->webform['components'][$key]['type'] == 'number'.
In the left column, I provide the machine name of the form field with $node->webform['components'][$key]['form_key'].

foreach ($node->webform['components'] as $key => $component) {
   if (isset(
$submission->data[$key][0])) {
    if (
$node->webform['components'][$key]['type'] == 'number') {
      if (
$submission->data[$key][0] > 0) {
'<tr><td>'.$node->webform['components'][$key]['form_key'].'<td>' . ($submission->data[$key][0]);

Good look in customizing your mail template!