Autoresponder with WebForm

Submitted by programmer on Fri, 12/21/2007 - 20:53.
::

Put this code in webform->edit>"Advanced Setting"->"Advanced Processing" and make changes according to your requirement. This code would be executed when the webform is submitted.

<?php foreach ($form_values['submitted'] as $field_id => $value) {
$component = $node->webformcomponents[$field_id];
if ($component['name'] == "Email Address" && valid_email_address($value)) {
$fromEmail = $value;
}
if ($component['name'] == "First Name") {
$fromName = $value;
}
}

$toemail = $form_values['submitted']['1197459807'];
$fromName = $form_values['submitted']['1197459739'];

$message = "$fromName,\n"
. "\n"
. "Thank you for visiting our web site. We shall contact you shortly. \n"
. "\n"
. "Thank you, \n NTB Team"
. "";

$subject = "Message from me";
$mailkey = "reply_anon";
$to = $toemail; //$fromEmail;
$from = "mysite@gmail.com";
drupal_mail($mailkey, $to, $subject, $message, $from);

?>

Post your Answer

  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Links to specified hosts will have a rel="nofollow" added to them.

More information about formatting options