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())
Comments
Webform email confirmation for Drupal 6
What would be the code to use for Drupal 6? It'd be highly appreciated, thanks.
Me too!
Yes I need this code for the 6.x versions.
Thanks in advance!
In Drupal 6
Here's the code I used. The drupal_mail() function has changed significantly in 6. I also used the webform's confirmation message for the email body.
This assumes there is a component on your webform called "email", that asks for the visitor's email address. If your component is named something else, you should change
$to = $form['submitted']['email']['#value'];
accordingly.Also, you may wish to change the email subject.
not working
I put this code in de additional processing field of my Webform from the Webform Modules and my email-field is the same.
But i didn't get any confirmation message.
I read somewhere that Webform ís not working with array's but strings and so you can't use these sign [] for the fields.
Is you're code really working?
similar issue
I'm having a similar issue, I need to get the value a user type and subsequentely submit from a textfield and I still do not have clear where to get it! I tried $form[submitted][name_of_the_field][#value] and many others but no luck for me! the bwst I could get was the output "Array". Does anybody know how to get the info I'm looking for and how to display it?
ciao.
try devel module
The code above is tested and working for me. I'm using Webform 6.x-2.3. It's possible the form structure changed in 2.4, I haven't looked.
One really easy way to find out what array keys you have is to install the devel module.
Then put
dpm($form)
in your code. dpm() will display the entire data structure in a nifty little DHTML widget.Great tip re devel!
Thanks for the
dpm()
tip, grendzy. I was getting an empty array when I tried to print out the form structure on my confirmation page, butdpm($form)
worked great.Using Webform 6.x-2.3 and the email code above works for me too.
Where to put dpm($form)?
There are several fields that accept PHP on the Webform configuration form. Among them are the 'Confirmation message or redirect URL' field, the redirect page itself, the 'Additional Validation' field, and 'Additional Processing' field. Where exactly do you put the call to the dpm($form) function?
Use $form_values, not $form
$to = $form['submitted']['email']['#value'];
might be more robustly done as:
$to = $form_values['submitted_tree']['email'];
which I think is more the "Drupal way".
http://www.fonant.com - Fonant Ltd - Quality websites
This works for me on Webform 6.x-2.9
Put this in the Additional Processing field:
Disable email responder?
Hi, How would you disable the webform auto email from the submitter? Not all of my forms require an auto email responder. Thanks much!
Uncheck "Conditional Email Recipients"
You would simply uncheck all the items underneath "conditional email recipients".
-----------------------------------------------
The Future is Open!
<
Also, be sure that the user who is submitting has the rights to use PHP on the permissions page
rename function
I had to rename:
function confirmation_reservation($key, &$message, $params)
to
function confirmation_reservation_mail($key, &$message, $params)
Before it would work
agreed
I also had to rename this function.
drupal_mail
takes "module" and "key" as its first two parameters, and then requires a "module_mail" function to do the sending. Since we're not using a module to provide this mail function, we have to explicitly provide it here. If we provide "confirmation_reservation" as the first argument todrupal_mail
, then the function we have to provide isconfirmation_reservation_mail
.To make things less confusing, we should probably also provide a different "key" to
drupal_mail
. The actual value of this "key" doesn't matter since we're not checking it in our mail function. Something like 'submitted' might work and not be confusing.So the call to
drupal_mail
might look like:And the signature of the mail function might look like:
LOST! - Where is "additional processing" edit block
Hi, not a nubie to PHP, but rusty on Drupal...
Running D5.2x and I wonder if someone can spot me on this... I am looking for the place on my form.... that I am tasked to edit (add confirmation coding)
"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"
I don't see the additional processing field... is this unique to the D6.x version?
Thanks.
See this URL for screenshot of what I am seeing: http://www.caled.org/economicdevelopment/Webform_advanced_settings.png
permissions
There should be two textfields right after "Submit button text" called "Additional validation" and "Additional processing". These are textfields where you're allowed to input PHP. If you don't see them, most likely you don't have the "use PHP for additional processing" permission. Go to /admin/user/access (if you have permission to view this page, of course), and make sure that "use PHP for additional processing" is checked for your role.
LOST! - Where is "additional processing" edit block
Hi, not a nubie to PHP, but rusty on Drupal...
Running D5.2x and I wonder if someone can spot me on this... I am looking for the place on my form.... that I am tasked to edit (add confirmation coding)
"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"
I don't see the additional processing field... is this unique to the D6.x version?
Thanks.
See this URL for screenshot of what I am seeing: http://www.caled.org/economicdevelopment/Webform_advanced_settings.png
ANY IDEAS?
Make sure you have the php
Make sure you have the php filter module turned on (admin/build/modules)
Drupal 6 Use CCK
I used CCK field for email body text.
so email_address - component email item
field_autorespond - text CCK field (choose "hidden" in teaser and full node view in "display field" when edit content type )
not working for me???
This is the error i get when i try and use the devel module:
warning: join() [function.join]: Invalid arguments passed in /is/htdocs/wp10475992_3K0QOVXJ1X/www/sites/all/modules/devel/krumo/class.krumo.php on line 657.
i have been trying for hours to get it to work.... I don know what the problem is. i even tried it with this simple script and it gave me the same error:
can anyone help me`?
how to show attachment's URL in the confirmation email?
We allow users to upload attachments while filling out the form. And, we want to show the URL of attachments in the confirmation email. What is the code for that?
We used the "regular" code:
"One Attachment: " . $params['one_attachment'] . "\r\n" .
but got something like this:
One Attachment:
a:10:{s:8:"filename";s:12:"ismaili1.pdf";s:8:"filepath";s:46:"sites/default/files/webform/psa/ismaili1_1.pdf";s:8:"filemime";s:15:"application/pdf";s:6:"source";s:14:"one_attachment";s:11:"destination";s:46:"sites/default/files/webform/psa/ismaili1_1.pdf";s:8:"filesize";i:3969078;s:3:"uid";s:1:"1";s:6:"status";i:1;s:9:"timestamp";i:1283286276;s:3:"fid";s:4:"3040";}
Any suggestion?
Thanks!
Using SID in confirmation email?
Does anyone know how to do this with webform 3.x and webform php modules? It used to be accessible in 2.x, but in 3.x the variable is not set. It does appear ?sid=X on the confirmation page though.
Easier way to write all form fields
Hello,
I'm emailing a copy of a submitted form with lots of fields.
The 6.x snippet on this page works great for me with webform 6.x-3.4.. but isn't there an easier way to write all fields to the email without $params for every single field.. I can't seem to make it happen.
.. something like
Thanks for your help.
Thanks for the
Thanks for the documentation.
One more option to use: based on the choices made by the submitter (checkbox, radio) you can change the message body.
my version of the script (drupal 6.14)
hi all, thanks to your disccussion I could solve my problem. Just for info I use drupal 6.14 and this is my script:
giorgio
thanks the code for drupal 6
thanks the code for drupal 6 is working but how can I add html to the message?
Webform confirmation emails on Drupal 7?
Hello everyone!
How about sending webform confirmation emails on Drupal 7 when an anonymous user completes the form?
I haven't found any info related to this anywhere on the web. Any help is appreciated.
Thanks!
Workaround with webform 6.x.3* version
All of the above suggested methods for retrieving data from webform submission failed for me (for 6.x.3* version of webform). Suggesting a workaround which is tested for D6.22 + Webform 6.x.3* version:
1. Changed the Redirection location from Custom URL (which was not working) to Confirmation Page.
2. Set Input filter as php
3. Entered the below piece of code in the Confirmation Message text box:
It worked. Let me know if anyone tried the above and faced issue.