$to = $form['submitted']['email']['#value'];
$from = variable_get('site_mail', '');
$body = drupal_html_to_text($node->webform['confirmation']);
$message = drupal_mail('webform_extra', 'reply', $to, language_default(), array('body' => $body), $from, TRUE);
function webform_extra_mail($key, &$message, $params) {
$message['subject'] = "Thanks for your interest.";
$message['body'] = $params['body'];
This is all well and good - however it is not very user friendly - here is what I propose:
Add an Auto-responder or Thank you Message in the Web-mail settings.
We need to collect the following data:
- The field that will be used when sending the thank you message
- The email Subject
- The email Body
All I want to accomplish here is when a user fills out a form they receive a thank you message
My approach is to build a custom module called 'webform_autoresponder'
____________________________________________________
My info file:
webform_autoresponder.info
***********************************************************************
; $Id: $
name = Webform AutoResonder
description = Enables Webforms to have a configurable Email Autoresponder field
core = 6.x
Right now I my schema will look something like this
____________________________________
NID / From / Subject / Message /
____________________________________
For the module itself I am using hook form alter to insert my fields where I would like them in the already existing webform edit form:
Naturally as this module becomes more mature I will post more code and eventually commit it to the Drupal repository. Please leave any advise or suggestions
/**
* Implementation of hook_form_alter().
* Change the way an existing form is rendered
*/
function webform_autoresponder_form_webform_node_form_alter(&$form, &$form_state){
$form['webform']['mail_settings']['ar_from'] = array(
'#type' => 'textfield',
'#title' => t('From'),
'#description' => t('If you create a conditional email recipient based off a field this is the address that it will be emailed from'),
'#default_value' => 'confemail',
);
$form['webform']['mail_settings']['ar_subject'] = array(
'#type' => 'textfield',
'#title' => t('Subject'),
'#description' => t('If you create a conditional email recipient based off a field this is the subject that will be in the email to them'),
);
$form['webform']['mail_settings']['ar_confemail'] = array(
'#type' => 'textarea',
'#title' => t('Confirmation Email message'),
'#description' => t('If you create a conditional email recipient based off a field this is the body that will be emailed to them'),
'#default_value' => 'confemail',
'#cols' => 40,
'#rows' => 10,
);
}
-Robert
No comments:
Post a Comment