New to Drupal, hope I am posting in the right place.

I am using the webform module to create a form, and I want to send a reply email after submission to the user's email they entered on said form. In the "webform advanced settings" section of the webform configuration setup screen there is a place for "Additional processing" which is where I am putting the code to send the email. When I hard-code an email address ($email = "xyz@mySite.com") it works fine, but doesn't work when I try to access the address entered by the user on the form. Here's the snippet:

<?php
// User's email address
$email = $form_values['email'];

// The subject
$subject = "Thank you for submitting";

// The message
$message = "Hello and thanks for the love!";

mail($email, $subject, $message, "From: me@mySite.com");
?>

$form_values['email'] doesn't seem to have a value. I don't know if my syntax is wrong, or if I'm just going about this in the wrong way, but any advice is greatly appreciated. Thanks.

Comments

knowlton’s picture

Still wrestling with this. I feel like the solution should be obvious, but can't seem to find it.

waynedrupal’s picture

I would also like to see a result for this. Anyone?

waynedrupal’s picture

Try the following:

http://drupal.org/node/153367

and...

http://drupal.org/node/142983

Hope that helps!

jonyamo’s picture

I haven't checked out the above posted links, so perhaps those are better solutions, but here is a quick way to set up an auto reply email. This version also sends the email as HTML. Just add the following code to the "Additional processing" field under the "Webform advanced settings" section.

<?php
  $to
= $form_values['submitted_tree']['email'];

 

$subject = '';

 

$message = '
    <html>
    <head>
    <title></title>
    </head>
    <body>
    </body>
    </html>
  '
;

 

$headers  = 'MIME-Version: 1.0' . "\r\n";
 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
$headers .= 'From: info@example.com' . "\r\n";
 
$headers .= 'X-Mailer: Drupal Webform (PHP/' . phpversion() . ')' . "\r\n";

 

mail($to, $subject, $message, $headers);
?>
edgar_estor’s picture

hi there
add the following code in the "additional processing"...

<?php
// User's email address
$email = $form_values['submitted_tree']['email_address'];

// The subject
$subject = "Thank you for submitting";

// The message
$message = "Hello and thanks";

mail($email, $subject, $message, "From: me@mySite.com");
?>

cheers

pinoy drupaloids

chandu7ee’s picture

Hi

i added above code to my web form in Additional Processing:., but after submitting its giving error message like as follows

500 Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/1.3.33 Server at test.com Port 80

ChandraShekar.A
Systems Analyst
Linearcube Inc.,

edgar_estor’s picture

Use webform module at http://drupal.org/project/webform and add the following under webform advance setting -> Additional Processing. Just be sure to configure the Conditional e-mail recipients under the same module

<?php
// User's email address
$email = $form_values['submitted_tree']['email_address'];

// The subject
$subject = "Thank you for Contacting Us";

// The message
$message = "
<html>
<head>
</head>
<body style="
font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#666">

blah ... blah... blah..


</
body>
</
html>
";

$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: info@email.com' . "\r\n";

mail(
$email, $subject, $message, $headers);
?>

cheers drupaloids

pinoy drupaloids

Marbot’s picture

Hi Edgar, it tried to get auto-reply working on my installation. The first version in plain text does not process ü, ä, etc. properly an the second version in html does not send an email to the editor of the form entry. If I configure conditional e-mail the editor of the form just gets the same entries sent as the administrator and not the intended message "blah ... blah... blah..". I am a bit confused. Perhaps there is an easy solution which I am not capable to find. Thank you for your help. Marbot

edgar_estor’s picture

sorry for the very late reply, I have been very busy lately, anyway heres the code I put inside the

"Additional Processing: ", you have to click "Webform advanced settings"

<?php
// User's email address
$email = $form_values['submitted_tree']['email_address'];

// The subject
$subject = "Thank you for Contacting my website";

// The message
$message = "
<html>
<head>
</head>
<body style='font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#666'>

<p>Heres where you will place your content of email</p>

<p>Best regards,</p>

<p style='color:#09C'><strong>Your Name</strong></p>


</body>
</html>
"
;

$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: myemail address' . "\r\n";

mail($email, $subject, $message, $headers);
?>

Please copy and paste that and inform me if it works
thanks

edgar

pinoy drupaloids

mikeschneik’s picture

Dear edgar,

your code don't show any errors.
But I can get only a copy of the Original Message to the customer email.

I can't send an personally email, like your example. (I've copy ande paste your code to my form)

I don't know why. Do I have to change an option in my webform?

Thanks

Mike

edgar_estor’s picture

Hi

Can you give me the details on all the setting you did for the autoreply module.. I will post mine later and lets compare notes

Thanks

pinoy drupaloids

mikeschneik’s picture

I didn't install the autoreply modul. I put directly your code into the webform.
Sorry, I havn't read about the module.
But I think I will finaly test it in a view days.

Thanks for your helping.

Mike

edgar_estor’s picture

great let me know if you encounter any problem

pinoy drupaloids

panks021’s picture

hello mikeschneik
i know the joomla but iam pretty new in drupal cms,
i copy paste the same code what u suggest us but can u plz tel me where can i get the autoreply modul ?
is there in the modul by defult or shall i install externally ?
Where shall i get the autoreply modul

Regards

Pankaj

Danny Englander’s picture

Works great, exactly what I was looking for, thanks! (http://drupal.org/node/277336#comment-2753720)

chandu7ee’s picture

Hi

i added below code in Webform advanced settings --> Additional Processing

<?php
$to
= $form_values['submitted_tree']['email'];
$subject = "Thank you for contacting MyComp";
$txt = "
<html>
 <head>IntelliSuggest Demo Request</head>
 <body><p>We will get back to you soon.</p><br /><br />
        <p>sincerely,</p>
         <p>MyComp Inc.</p>
 </body>
</html> "
;

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
$headers .= 'From: info@mycomp.com' . "\r\n";

mail($to,$subject,$txt,$headers);

?>

i created a page with a name as thank you. and added this url to the web form under

Confirmation message or redirect URL:

http://mycomp.com/content/thank-you

but after submitting my form., it shows a blank white page with url as form url.

how can i redirect user after form subnitting? any idea? please help me as soon as possible.

here auto reply to user working properly. user was able to get a response after each form submission.

Chandu
+91 9989902757

ChandraShekar.A
Systems Analyst
Linearcube Inc.,

chandu7ee’s picture

Hi

i added below code in Webform advanced settings --> Additional Processing

<?php
$to
= $form_values['submitted_tree']['email'];
$subject = "Thank you for contacting MyComp";
$txt = "
<html>
 <head>IntelliSuggest Demo Request</head>
 <body><p>We will get back to you soon.</p><br /><br />
        <p>sincerely,</p>
         <p>MyComp Inc.</p>
 </body>
</html> "
;

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
$headers .= 'From: info@mycomp.com' . "\r\n";

mail($to,$subject,$txt,$headers);

?>

i created a page with a name as thank you. and added this url to the web form under

Confirmation message or redirect URL:

http://mycomp.com/content/thank-you

but after submitting my form., it shows a blank white page with url as form url.

how can i redirect user after form subnitting? any idea? please help me as soon as possible.

here confirmation email to user working properly. user was able to get a response after each form submission.

Chandu
+91 9989902757

ChandraShekar.A
Systems Analyst
Linearcube Inc.,

edgar_estor’s picture

i dont think you needed to create a new page for the thank you note since it is already created under the same module. it will automatically redirect to the thank you once you added a code under the form additional

pinoy drupaloids

makbul_khan8’s picture

Hey friends
After reading all comment, i would like you all to avoid all that process.
I am using drupal webform module version = "6.x-2.10" and i can't see the link of "Additional processing" in "webform advanced settings" section of the webform configuration setup screen.

/** Even searching for that is wasting time**/
Here is the solution::
goto webform -> E-mails
1) Add email to, Subject, from by clicking add button.
Description: Here you may want to add the email to the Address of addressee. For eg. "admin@example.com".
and from field value can be value of "form component-> name". for eg "your email address".

2) Confirmation email to the user
Description: goto webform -> E-mails. Their you will find two radio button a) Address b)Component value.
Select a) Address radio button and click on Add.
and do the rest of the setting in the same manner as you done for first one.

If you find this helpful. Do pass this link to your friends.

Thank You.

edgar_estor’s picture

congrats im very happy for you

pinoy drupaloids