Send form confirmation email using webform additional processing

| | Comments (5)

Webform is a great module, but it doesn't send confirmation email, so here is a quick fix if you are running on Drupal 6.x.

To get the submitted value of a form component, you can use $form_values['submitted_tree']['component_key'] where component_key should be replaced by your component key. If the component is in a fieldset, access it by $form_values['submitted_tree']['fieldset_key']['component_key'] where fieldset_key should be replaced by your fieldset key.

To send the email I chose to use drupal_mail() function, of course there are other ways.

Here is an example:

$from = "example@example.com";
$to = $form_values['submitted_tree']['email'];
$user = $form_values['submitted_tree'['name'];
$body = "Hello " . $user . ",\nThis is a message.";
drupal_mail('webform_extra', 'confirmation_key', $to, language_default(), array('body' => $body), $from, TRUE);
function webform_extra_mail($key, &$message, $params) {
$message['subject'] = "Confirmation email";
$message['body'] = $params['body'];
}

5 Comments

Apologize for my bad english, I deliberate on its a precarious drama of your writing. Well I obtain faced alot of difficulties in this condition but your article determination definately relieve me in future. Say thank you You

Hello from Russia!
Can I quote a post in your blog with the link to you?

Hi Polprav! Of course you can do that.

Marika

That codeblock has issues; the $user var there will conflict with the $user object and log you out, as well as throw mysql errors. This one works:

$from = "example@example.com";
$to = $form_values['submitted_tree']['email_address'];
$submitter_name = $form_values['submitted_tree']['name'];
$body = "Hello " . $submitter_name . ",\nThis is a message.";
$confirmation_key = "confirmation_email";
drupal_mail('webform_extra', 'confirmation_key', $to, language_default(), array('body' => $body), $from, TRUE);
function webform_extra_mail($key, &$message, $params) {
$message['subject'] = "Confirmation email";
$message['body'] = $params['body'];
}

hope that helps :)

I would like to exchange links with your site www.miphol.com
Is this possible?

Leave a comment