HI folks,

I'd love to see an autoresponder option for an individual webform. The scenario - user fills out form, email is sent to admin, and autoresponse is sent to user.

Thanks,
Dan

Comments

BarisW’s picture

That would be great indeed! Looking out for that :)

BarisW’s picture

That would be great indeed! Looking out for that :)

Baris Wanschers
Sixcolored

gvdvenis’s picture

I think that autoresponder is not a correct description for this. An autoresponder responds to an incoming message, This would me more like a confirmation message i guess... You could have a look at the actions module. I believe that with this module it's possible to send out an email as a reaction to certain events like submitting webforms... The only complication would be how to get form data in the E-Mail sent by the action module... Just a few late night thoughts...

seakayjay’s picture

I'm looking forward for this feature as well.

mtndan’s picture

Hi again,

I'm running Drupal 5.1 and I was able to accomplish this by putting the following code in the "Advanced Settings" -> "Additional Processing" field:

<?php
foreach ($form_values['submitted'] as $field_id => $value) {
  $component = $node->webformcomponents[$field_id];
  if ($component['name'] == "E-mail Address" && valid_email_address($value)) {
    $fromEmail = $value;
  }
  if ($component['name'] == "Name") {
    $fromName = $value;
  }
}
   
$message = "$fromName,\n"
. "\n"
. "Thank you for visiting my web site. I hope that it was useful. If there is anything that I can help you with, please contact me. My business is based on building long term relationships with my clients as their personal real estate consultant. I would love the opportunity to share my high level of service with you. Your contacts with me will always be kept confidential.\n"
. "\n"
. "Please check back on my website for more information at www.Come2ColoradoSprings.com\n"
. "\n"
. "In order to help you get as much relevant information as possible to make your best move, I am sending you a link to a online interactive relocation tour.  I hope that this is helpful in giving you some of the vital statistics for Colorado Springs.  Please let me know if you have any questions and I am certainly looking forward to serving you and helping make this move your very best!\n"
. "\n"
. "Click on the link below to take your relocation tour:\n"
. "http://www.makeyourbestmove.com/Relo/index.htm\n"
. "\n"
. "My best,\n"
. "Vicki French Westapher\n"
. "\n"
. "ABR,CRS,GRI,SRES,ePRO,QSC, LHP, Broker Associate\n"
. "\n"
. "Make Your Best Move!\n"
. "Licensed in Colorado\n"
. "\n"
. "\n"
. "Oh, by the way...I'm never too busy for your referrals. If you hear of anyone that might be thinking of buying or selling property and would appreciate the high level of service that I provide, please give me a call with their name and number and I'll follow up and take great care of them. Don’t forget that I can help anyone, anywhere in North America.\n"
. "\n"
. "719.495.8007 office\n"
. "888.773.6031 tollfree\n"
. "719.623.0642 fax\n"
. "vicki@makeyourbestmove.com\n"
. "http://www.MakeYourBestMove.com\n"
. "\n"
. "RE/MAX Properties, Inc.\n"
. "1740 Chapel Hills Drive\n"
. "Colorado Springs, Colorado 80920\n"
. "\n"
. "";

$subject = "Relocation Information for Colorado Springs";
$mailkey = "relo_anon";
$to = $fromEmail;
$from = "vicki@makeyourbestmove.com";
drupal_mail($mailkey, $to, $subject, $message, $from);
?>

Works great!

seakayjay’s picture

Thank you so much. This is what I'm looking for.

seakayjay’s picture

I know there is a way that you can display the form data in the autoresponder email? Base on the code provided by mtndan, I'm able to get the form data in textfield to display in email. But how to do I display the data for select and date components? Because the data display code provided won't work for select and date components.

Basically, what i'm trying to do is to send an autoresponder email to the form user with all the results of the data that he/she submitted.

Anyone can help?

seakayjay’s picture

any support for this? my boss gave me another 2 days to figure this out. All I have to do is to display the data for both select and date components on the mail message.

Please... anyone? i'll really appreciate it.

seakayjay’s picture

It's OK now. I managed to get the data displayed mail message.

For date component:
<?php $form_values['submitted']['dob']['day']."/".$form_values['submitted']['dob']['month']."/".$form_values['submitted']['dob']['year'] ?>

For select component (I did it in a long way but I believe there is another way to do this):

<?php 
$sub_newsletter = $form_values['submitted']['newsletter']['local_news']."<br />"
.$form_values['submitted']['newsletter']['world_news']."<br />"
.$form_values['submitted']['newsletter']['entertainment']."<br />"
.$form_values['submitted']['newsletter']['technology']."<br />"
.$form_values['submitted']['newsletter']['opinion']."<br />"
.$form_values['submitted']['newsletter']['business']."<br />";
$sub_newsletter_clean = str_replace("0<br />", "", $sub_newsletter); 
?>

Ok... thank you all. webform is a nice module.

gvdvenis’s picture

Here is the code, To get it to work, do the following:

Define a form containing:
- Select field: "Name" (Single select)
- Select field: "Hobbies" (Multi select)
- Date field: "Birthday"

Put the following code into the "Advanced Settings" -> "Additional Processing" field:


$body = '';

foreach ($form_values['submitted'] as $field_id => $value) {
  $component = $node->webformcomponents[$field_id];
  // select with only one selectable option
  if ($component['name'] == "Name") {
    $fromName = $value;
    $body .= "\n" ."Name:" ."\n" .$value ."\n";
  }
  // select with multiple selection options
  if ($component['name'] == "Hobbies") {
    $body .= "\n" ."Selected hobbies:" ."\n";
    foreach ($value as $key => $selvalue){
      if ($selvalue != '0') $body .= "$selvalue" ."\n";
    }
  }
  // date value
  if ($component['name'] == "Birthday") {
    $body .= "\n" ."Birthday:" ."\n";
    $body .= "$value[day] - $value[month] - $value[year]" ."\n";
  }
}
// uncomment line below to view results on screen after submit
//echo(nl2br($body));

$message = "Dear $fromName," ."\n"
. "\n"
. $body
. "\n";

$subject = "Testmessage";
$mailkey = "some_key";
$to = "Info@localhost.com";
$from = "me@localhost.nl";
drupal_mail($mailkey, $to, $subject, $message, $from);

After this take a day off, and tell your boss you're working out this problem :)

Regards,

Gert

seakayjay’s picture

Thank you Gert. Now I can take a rest today. =)

mtndan’s picture

&uotHi again folks,

I'm attempting to get this working to send an html email. The changes I've made are below. It doesn't seem to be working, so any ideas would be appreciated! Thanks!

<?php
foreach ($form_values['submitted'] as $field_id => $value) {
  $component = $node->webformcomponents[$field_id];
  if ($component['name'] == "E-mail Address" && valid_email_address($value)) {
    $fromEmail = $value;
  }
  if ($component['name'] == "Name") {
    $fromName = $value;
  }
}
   
$message = chunk_split(base64_encode("<html>\n"
. ;<head>\n"
 . "<title></title>\n"
 . "</head>\n"
 . "<body>\n"
. "<p>$fromName,</p>\n"
. "<p>Thank you for visiting my web site. I hope that it was useful. If there is anything that I can help you with, please contact me. My business is based on building long term relationships with my clients as their personal real estate consultant. I would love the opportunity to share my high level of service with you. Your contacts with me will always be kept confidential.</p>\n"
. "<p>Please check back on my website for more information at <a href=\"http://www.come2coloradosprings.com\">www.Come2ColoradoSprings.com</a></p>\n"
. "<p>In order to help you get as much relevant information as possible to make your best move, I am sending you a link to a online interactive relocation tour.  I hope that this is helpful in giving you some of the vital statistics for Colorado Springs.  Please let me know if you have any questions and I am certainly looking forward to serving you and helping make this move your very best!</p>\n"
. "<p><font size="4"><strong>Click on the link below to take your relocation tour:</strong></font></p>\n"
. "<p><a href=\"http://www.makeyourbestmove.com/Relo/index.htm\">http://www.makeyourbestmove.com/Relo/index.htm</a></p>\n"
. "<p>My best,</p>\n"
. "<p>Vicki French Westapher</p>\n"
. "<p>ABR,CRS,GRI,SRES,ePRO,QSC, LHP, Broker Associate</p>\n"
. "<p>Make Your Best Move!<br/>\n"
. "Licensed in Colorado</p>\n"
. "\n"
. "<p><em>Oh, by the way...I'm never too busy for your referrals. If you hear of anyone that might be thinking of buying or selling property and would appreciate the high level of service that I provide, please give me a call with their name and number and I'll follow up and take great care of them. Don’t forget that I can help anyone, anywhere in North America.</em></p>\n"
. "<p>719.495.8007 office<br/>\n"
. "888.773.6031 tollfree<br/>\n"
. "719.623.0642 fax<br/>\n"
. "vicki@makeyourbestmove.com<br/>\n"
. "http://www.MakeYourBestMove.com</p>\n"
. "<p>RE/MAX Properties, Inc.<br/>\n"
. "1740 Chapel Hills Drive<br/>\n"
. "Colorado Springs, Colorado 80920</p>\n"
. "</body>\n"
 . "</html>\n"
 . ""))
 . "\n;

$headers = array( 
    'MIME-Version' => '1.0', 
    'Content-Type' => 'text/html; charset=ISO-8859-1; format=flowed', 
    'Content-Transfer-Encoding' => 'base64', 
	'From' => 'vicki@makeyourbestmove.com',
    'X-Mailer' => 'Drupal' 
  );
$subject = "Relocation Information for Colorado Springs";
$mailkey = "relo_anon";
$to = $fromEmail;
drupal_mail($mailkey, $to, $subject, $message, $headers);
?>
seakayjay’s picture

i think you miss out \ before " in <a href="http://www.come2coloradosprings.com\">www.Come2ColoradoSprings.com</a>

quicksketch’s picture

Status: Active » Closed (fixed)
ira42’s picture

I had this code working beautifully with D5.x, but I think the drupal_mail syntax has changed in D6.x.

Any chance that someone's got this working in Drupal 6 and could share the updated code?

Tx!

waynedrupal’s picture

Instead of having an email componant and using that to send to user, I have the webform only for registered users. So, I would not have :

if ($component['name'] == "E-mail Address" && valid_email_address($value)) {
    $fromEmail = $value;
  }

and hense, not have $to = $fromEmail; but I would want the form to go to the registered user who is logged in and filling out form. What would I put in $to = $registered user; for this to be sent to the registered user?

I have tried $to = $user; but that did not send the email to the registered user. Any suggestions please?

Thanks.

waynedrupal’s picture

Hi. I have entered this into Additional Processing, but it does send an email to the person filling out the form.

<?php
foreach ($form_values['submitted'] as $field_id => $value) {
  $component = $node->webformcomponents[$field_id];
  if ($component['name'] == "E-mail Address" && valid_email_address($value)) {
    $fromEmail = $value;
  }
  if ($component['name'] == "Name") {
    $fromName = $value;
  }
}
   
$message = "$fromName,\n"
. "\n"

. "\Message in here.";

$subject = "Quote Form";
$mailkey = "webform-submission";
$to = $fromEmail;
$from = "me@my-email-address.com";
drupal_mail($mailkey, $to, $subject, $message, $from);
?>

I am using Webform 5.20 on Drupal 5.7.

The two componant names I am using are "E-mail Address" and "Name" (without quotes). Should "valid_email_address" be something specific here?

Is there anything that I need to change that should be customised to my configurations (such as $node->webformcomponents to something else)?

The only thing I can think of is in the Advanced Settings, Additional Processing, there is not an option for Input Types, to select php code option. Does webform automatically know to use php code for the Aditional Processing?

Any help would be appreciated. Thanks!

waynedrupal’s picture

My thoughts about the php code within input formats is invalid because I have successfully been able to get following to work:

<?php
// User's email address
$email = "my@email-address.com";

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

// The message
$message = "Hello World";

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

But how do I get the other to work so that message gets sent to email address that is filled in email component?

jarkko’s picture

Try $user->mail, that works for me. Remember put: $global $user; before that line!

edit: this reply is for post #16.

Glowingtree’s picture

Hey, this is just what I'm looking for. (re: mtndan's post 5 and 12) Do you mind making a distinction
from the over-all code values needed and the ones that only pertain to your form?
i don't know what values to bring in from my specific form. i am not using any email
validation snippet or duplicate fields for email addresses. All I really need is the email address
that people put into my form-component that I named "email" to show up for the " $to= " variable that is a part of drupal_mail function.

I would be happy to get just that working and a plain text string for the message

mtndan’s picture

Hi Glowingtree,

The only values that pertain to the form specifically are:

$component['name'] == "E-mail Address"
$component['name'] == "Name"

These are actual webform fields in my form.

(and the actual autoresponse text)

Glowingtree’s picture

i put the code below in the additional processing field in Webforms settings,
in its most simple form. I do not have any email validation field or code happening,
so I omitted && valid_email_address($value) from the first IF line

still does not send a test email after I fill out the form (i'm filling out form tests
using my drupal admin account, using a seperate test email)
did I miss anything?

<?php
foreach ($form_values['submitted'] as $field_id => $value)
 { 
     $component = $node->webformcomponents[$field_id];
     
if ($component['name'] == "email")
     { $fromEmail = $value;}

  }

  
$message = "Thank you for downloading the form";

$subject = "test subject";
$mailkey = "testkey";
$to = $fromEmail;
$from = "jeremy@glowingtree.com";
drupal_mail($mailkey, $to, $subject, $message, $from);
?>

the name of the user email field is "email"

mtndan’s picture

Have you confirmed the site sends out other emails normally, like new user notifications?

Glowingtree’s picture

yep, creating dummy accounts gets the emails sent pretty fast.

I tried setting up Actions module (5.x vers) to do an auto-response email in
conjunction with, but submitting a webform doesn't show up
as one of the "action triggers"

mtndan’s picture

Sorry, I'm stumped...

Glowingtree’s picture

if the code I'm showing you looks correct to you, than there is probably some
weird module conflict, can't they just all get along!! I have Logintoboggan,
it does auto-emails, maybe its getting in the way of this.

morganchad’s picture

I've referred to this page several times wondering why I couldn't get it to work - forgetting that it was Drupal 5.x and I'm using 6.x. It seems others here have had the same problem.

A quick search filtered by version and for confirmation email instead of auto-responder (which is the correct terminology as noted above) solved the problem. Here is the page that fixed it for me
http://drupal.org/node/333707

It's nice doing this through themeing and much more powerful that trying to use the advanced settings as described in this thread.

MohammadMoussa-Lebanon’s picture

Version: 5.x-1.4 » 6.x-2.1
Assigned: Unassigned » MohammadMoussa-Lebanon
Status: Closed (fixed) » Active

sorry this is really what i want but please can you till me where i can place this code ??!!:S:S:S im a new drupal user and i dont know where to put this code.i just want also to ask if can i send activation link in this email. thanks alot man,

quicksketch’s picture

Version: 6.x-2.1 » 5.x-1.4
Assigned: MohammadMoussa-Lebanon » Unassigned
Status: Active » Closed (fixed)

Everything in this issue is completely unnecessary if you're using the 3.x version of Webform. Webform 3.x can now send out individual e-mails to the administrator and user with separate templates, all from the UI without writing any code. I'm closing this issue again as it's no longer relevant to current users of Webform.

chandu7ee’s picture

Version: 5.x-1.4 » 6.x-2.0-beta1
Status: Closed (fixed) » Needs work

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

quicksketch’s picture

Status: Needs work » Closed (won't fix)

I highly discourage the use of the Additional Processing fields (which is why they're removed in the 3.x versions). Support on using them is not provided.

jakemonO’s picture

This is great! Thanks! How do I send an email (thank you email) to an anonymous user that has filled out an e-mail address field (required)

EvanDonovan’s picture

Issue summary: View changes

What would be the new approved method? Rules + Mime Mail?