0 down vote favorite

I have a webform and I want to send an email to a user on submit action on this webform.

Note: I do not want to use the inbuild emails module for webform as it has some limitations related to the functionality that i want to achieve. Hence I want to send a test email on Submit action via a custom PHP.

I know how to write PHP for a webform but I need some guidance on how to use it for sending emails.

Also I want to send emails on submit action only if user selects a select option on this form.

How can I do this? Please help I am stuck on this for a long time now.

I tried using Rules module but I can not check the webform field values in rules.

1 Answer 1


It's possible that you could use either hook_webform_submission_presave or hook_webform_submission_insert in a custom module, check for the your webform component value (i'd assume it's in $submission) and then fire your email.

In a custom module, add your hook like so.

function mymodule_webform_submission_insert($node, &$submission){
  // Use devel to investigate the variable

Creating custom modules for Drupal 7 or Drupal 6. Tutorial.

Use Devel module to investigate your variables, as seen in my example above.


  • Thanks Jason for your answer. Can you please tell me about how to add hooks? I am really new to drupal Dec 26, 2013 at 23:37
  • I've updated my answer to include information about module development. Good luck!
    – Jason
    Dec 27, 2013 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.