| 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.
  • 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.
  • Click Save component.
  • Finish creating the rest of your webform.

3) Customize the emails from the form

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

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.