I am using a webform module to create a contact us form. The customer has asked for a dropdown list for the visitor to select whom they would like to contact (web administrator/general enquiry). Is there a way to change the TO email depending on the selection? Or is there another way of achieving this?
|
Here's how I did it in Drupal 7, without the use of any other add-on modules:
|
|||||||||||
|
|
You can achieve this with the Webform rules module. You can catch every webform submit and then apply actions on it depending on the submit values. This module helps exposing webform events to the rules module. The Rules module is used to trigger actions on defined events, so for example when a webform is submitted you can create a condition (in Rules) that checks the dropdown value and then trigger an action that sends the mail accordingly. You can have as many rules as diferent recipients. |
|||||
|
|
Build your own module, hook_form_alter($your_forms_id) and add your own submit handler like
PS:Your default (webform) submit handler is executed also ..
|
|||
|
|
|
Have a look at issues [#800350] or [#1026758]. In short: you can do so by adding the following (templated) code:
By using hook_mail_alter you will also catch resubmissions, that most other solutions don't. |
|||
|
|
