Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello Everybody,
To my mind it makes sense to let a custom module a chance to alter list of webform emails, as it will let to take emails depending on form fields values.
For instance:
A webform has a country dropdown and we would like to send a submission to the email address which depends on the selected country.
I propose to add this possibilty after
// Get the list of e-mails we'll be sending.
$emails = isset($emails) ? $emails : $node->webform['emails'];
line of webform_submission_send_mail function
Comments
Comment #1
Esculap CreditAttribution: Esculap commentedComment #2
sunshinee CreditAttribution: sunshinee commentedHi, I can't speak to additions to the module, but are you aware you can use the [key] value in a select component to set an email address like:
myemail1@domain.com|Country1
myemail2@domain.com|Country2
...and so forth?
Also, it is possible to accomplish this using the Rules module or Webform hooks-- mymodule_webform_submission_presave() or mymodule_webform_submission_insert() should both be able to modify or send to additional emails.
Hope this helps!
Joy
Comment #3
Esculap CreditAttribution: Esculap commentedHi. Thank you for your quick response. The issue can be closed
Comment #4
DanChadwick CreditAttribution: DanChadwick commentedComment #5
Turek CreditAttribution: Turek commentedWell exposing your email addresses as proposed in #2 isn't that good, as spam bots of all kinds would grab those emails easily and start spamming. And sometimes people just don't want to unveil their emails.
I came across similar situation that we have a dropdown of departments where email should go, but this is also dependent on the language user is using. So the same option in the dropdown could go to different email based on the language.
Tried adding email field to the form, and then setting up form to send to that email, but there is no hook where I could populate that field dynamically after submitting the form.
Such hook would be useful to have.
Comment #6
Turek CreditAttribution: Turek commentedComment #7
Turek CreditAttribution: Turek commentedIgnore my previous post, was able to sort it out this way :-)
Comment #8
DanChadwick CreditAttribution: DanChadwick commented