Sending confirmation email

Last updated on
30 April 2025

To send a confirmation email via additional processing you can use the script below.

It sends a confirmation email with data collected with the webform module

This assumes you have components in the webform called first_name, last_name, telephone and quantity

The names of the components are taken form the field "Field Key" in the fieldset "advanced settings" of the component

The whole php script including the php tags goes into the "additional processing" field in the fieldset "webform advanced setting" of the webform
Alternatively the script can placed in a php file on the server and called from the "additional processing" using the php include function

for Drupal 6


/**
 * this script send a confirmation email with data collected with the webform module
 * this assumes you have components in the webform called first_name, last_name, telephone and quantity
 * the names of the components are taken form the field "Field Key" in the fieldset "advanced settings" of the component 
 * the whole php script including the php tags goes into the "additional processing" field in the fieldset "webform advanced setting" of the webform
* alternatively the script can placed in a php file on the server and called from the "additional processing" using the php include function
 */

// fetch data submitted via webform for later use in the body of the email
$params['first_name'] = $form_values['submitted_tree']['first_name'];
$params['last_name'] = $form_values['submitted_tree']['last_name'];
$params['telephone'] = $form_values['submitted_tree']['telephone'];
$params['quantity'] = $form_values['submitted_tree']['quantity'];

// fetch recipients email adrres from data submitted via webform
$to = $form_values['submitted_tree']['emailaddress'];

// set sender
$from = "luca.brasi@daluca.be";

// install devel module and uncomment next line to see entire data structure in a nifty little DHTML widget
// dpm($form);

// drupal message on confirmation page
drupal_set_message('Form has been sent');

// send the confirmation mail
drupal_mail('confirmation_reservation', 'confirmation_reservation_mail', $to, language_default(), $params, $from);

// construct email

function confirmation_reservation_mail($key, &$message, $params) {
  $message['subject'] = "Confirmation of your reservation at Da Luca";
  $message['body'] = "
Dear " . $params['first_name'] . " " . $params['last_name'] . "
Thank you for reserving a table for " . $params['quantity'] . " at our restaurant
In case you don't turn up we will now where to find you at" . $params['telephone'] . " 

Kindest regards,
Luca Brasi
Da Luca, Fish & Seafood Restaurant
";
	}

for Drupal 5

$to = $form_values['submitted_tree']['emailaddress'];
$first_name = $form_values['submitted_tree']['first_name'];
$last_name = $form_values['submitted_tree']['last_name'];
$telephone = $form_values['submitted_tree']['telephone'];
$qty = $form_values['submitted_tree']['quantity'];
$body = "Dear " . $first_name . $last_name . " \n\n
Thank you for reserving a table for " . $qty . " at our restaurant \n
In case you don't turn up we will call you at" . $telephone . " \n\n

Kindest regards,\n
Luca Brasi \n
Da Luca, Fish & Seafood Restaurant\n 
Bladibla\n 
Bladibla\n 
Bladibla";

$mailkey = "reservation";
$subject = "Reservation from" . $first_name . $last_name . ;
$from = "luca.brasi@daluca.be";

drupal_mail($mailkey, $to, $subject, $body, $from, $headers = array())

Help improve this page

Page status: Not set

You can: