Drupal 7: Webform: Send Email Custom PHP on Webform submit 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.
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, &amp;$submission){
  // Use devel to investigate the variable
  dsm($submission);
}


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

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

Jason.