Skip to content

Instantly share code, notes, and snippets.

@vkareh
Created May 17, 2012 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vkareh/2721620 to your computer and use it in GitHub Desktop.
Save vkareh/2721620 to your computer and use it in GitHub Desktop.
<?php
/**
* Form submit...
*/
function my_module_submit($form, $form_state) {
$email = $form_state['values']['email'];
$message_type = $form_state['values']['message_type'];
$params = array('form_values' => $form_state['values']);
drupal_mail('my_module', $message_type, $email, language_default(), $params);
}
/**
* Implementation of hook_mail().
*/
function my_module_mail($key, &$message, $params) {
switch ($key) {
case 'message_type':
$message['subject'] = $params['form_values']['subject'];
$message['body'][] = $params['form_values']['message'];
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment