Sending Drupal Webform Results to Different Email Addresses

tutuploadsmedia_1339685890414.png

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

Author

  • Steve Burge

    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.

0 0 votes
Article Rating
Subscribe
Notify of
11 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Grincheux
Grincheux
11 years ago

Nice trick, but what about spambots, who scan source code, and will find those addresses?

An issue is opened here for conditional emails : [url=http://drupal.org/node/687606]http://drupal.org/node/687606[/url]

tadams
tadams
11 years ago

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
tadams
11 years ago

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
11 years ago

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

Srdjan Marjanovic
Srdjan Marjanovic
9 years ago

Nice! Thank you!

PHP Developer
PHP Developer
9 years ago

Terrible solution. Expect loads of spam coming your way.

upendra
upendra
8 years ago

If I have duplicate keys,this would fail eventually. Looking to use duplicate keys as email for different values.
email1|value1

email2|value2

email1|value3

email3|value4
If these are my key|value pairs the above trick is failing. please email me back if you have a solution to my scenario

abdulbasitnawab
abdulbasitnawab
8 years ago

Not a preferable solution as in the source the email list will be available to hackers and spamers. May be we need to use the webform hooks etc.

v_akshat
7 years ago

How to set the default email address if no options is selected from the options list. ?

daniel-pickering
7 years ago
Reply to  akshat verma

Hi akshat,
You need to define the default as mentioned above.

11
0
Would love your thoughts, please comment.x
()
x