Drupal Tutorials and Blog Posts

Sending Drupal Webform Results to Different Email Addresses

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

Comments

 
Grincheux
#1 Grincheux 2012-06-15 11:15

Nice trick, but what about spambots, who scan source code, and will find those addresses?
An issue is opened here for conditional emails : drupal.org/node/687606
 
 
steve
#2 steve 2012-06-15 12:16

Thanks for the link, Grincheux.

Looks like a useful patch. It's a shame it missed becoming part of the core for the next release.
 
 
tadams
#3 tadams 2013-04-04 14:41

Does sending email based on a selected option work in the same manner if MULTIPLE options are allowed to be selected?

In other words, lets say...

I have a select options field multiple options are enabled called: Need Assistance


There are five options each with a different email that a user can select and ask for assistance.

the EMAIL TO setting for this component is set to: Need Assistance

If a user selects 3 out of the 5 select options, will an email be sent to ALL 3 of the email addresses associated with each of options selected by the user?
 
 
tadams
#4 tadams 2013-04-04 15:11

Is it possible to embedd a hyperlink or email address into the text of select option?


In other words, if I have a the following options listed in a select option:

0|Business Degree Information
1|Nursing Degree Information

etc...

Is there a way to list make the text "Business Degree Information" or include a hyperlink in an option list?
 
 
JudyAC
#5 JudyAC 2013-04-08 20:06

I tried this and can't find the appropriate field type after creating my webform after the Drupal Webform class model. I just see Select list, but can't figure out how to have the display be only the department rather than the e-mail address pipe and the department. Is there another select option I'm not seeing? I'd like it to be just department, but the e-mail selected when the option is selected from the list.
Thanks, JudyAC
 

Add comment


Security code
Refresh

blog-ad

Start Online Training

Members get access to all our video training. That's 1,142 training sessions in Joomla, Drupal, WordPress and Coding.

Manage All Your Joomla Sites

adminicredible

With Admincredible you can update and manage all your Joomla sites. If you have 5 or 500 sites, Admincredible will make your life easier! Visit Admincredible.com.

Latest Comments

The License for Our Tutorials

All of our tutorials are published under the Creative Commons Attribution-NonCommercial license. This means:

  • You can re-use these tutorials.
  • You can modify these tutorials.
  • You must link back to our original tutorial.
  • You can't use these tutorials commercially.

Click here to read the full license.

Open Source Training is not affiliated with or endorsed by the Joomla, WordPress or Drupal projects.
All product names and trademarks are the property of their respective owners.

Copyright 2013 Open Source Training, LLC. All rights reserved.