Sending Drupal Webform Results to Different Email Addresses

| Drupal

One of our students is using Drupal's Webform module for their site's contact form.

They asked if it was possible to send submissions to different e-mail addresses based on a choice made in the form. The student wanted to send different submissions to different departments in the company.

Yes, it is possible and we're going to show you how.

Before we start, here are two useful links:

1) Install Webform

2) Create a Webform

  • Go to Add content > Webform and create a new webform.
  • Add a "Select options" component to your form as in the image below.
tutuploadsmedia_1339685890414.png
  • Click Save.
  • Find the Options area.
  • Place an email address on the left, then a pipe bar and then the label that you want visitors to choose.
tutuploadsmedia_1339684567328.png
  • Click Save component.
tutuploadsmedia_1339684964729.png
  • Finish creating the rest of your webform.

3) Customize the emails from the form

  • Click the e-mails tab oin the top-right.
tutuploadsmedia_1339686334965.png
  • Set Component value to Department.
  • Click Add.
tutuploadsmedia_1339686442855.png
  • Make sure that the E-mail to address field is set to Component: Department.
tutuploadsmedia_1339684698921.png
  • Click Save e-mail settings.
  • Your email setting will now look like the image below.
tutuploadsmedia_1339686773900.png
  • Now visit your form and your webform will now send to different e-mail addresses, depending on the selection made under Department.
tutuploadsmedia_1339685023893.png

About the author

Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.