The University of Arizona

Webforms: creating custom email templates

Drupal websites hosted on Pantheon that send outgoing emails must use SendGrid to have any hope of having those emails delivered.

However, SendGrid does not play nice with the Drupal module Webform -- the module responsible for most of our website-originated emails.

If you use the default Webform email template, the resulting email formatting strings all the fields and their values together into one paragraph, no line breaks between fields.


Field 1: value of field 1 Field 2: value of field 2 Field 3: value of field 3.

There are two ways to fix this.

1. Wrap the whole form in a fieldset. This should work although the resulting text is in a weird Courier font.

2. Use a custom template and specify each field:

  • Edit the Webform and go to Form components.
  • Grab the field labels and form keys for each component.
  • Reformat the list as follows: Field Label: [submission:values:form_key] where form_key is replaced with the machine name of the field.


Your Name [submission:values:your_name]

Your Email [submission:values:your_email]

Room # [submission:values:room_number]

Telephone # [submission:values:telephone_number]

Subject [submission:values:subject]

  • For each email, edit the email, and under E-MAIL TEMPLATE, select "Custom Template."
  • Then replace [submission:values] with your list of specific fields as above.
  • Note that if any field sets are in use, you have to add the machine name of the field set to the field string, like so: [submission:values:fieldset_name:form_key]