function mimemail_example_form_submit in Mime Mail 7
Form submission logic for the email contact form.
File
- modules/
mimemail_example/ mimemail_example.module, line 154 - Core and contrib hook implementations for Mime Mail Example module.
Code
function mimemail_example_form_submit($form, &$form_state) {
$values = $form_state['values'];
$module = 'mimemail_example';
$key = $values['key'];
$to = $values['to'];
$language = language_default();
$params = $values['params'];
if (!empty($values['from_mail'])) {
module_load_include('inc', 'mimemail');
$from = mimemail_address(array(
'name' => $values['from'],
'mail' => $values['from_mail'],
));
}
else {
$from = $values['from'];
}
$send = TRUE;
$result = drupal_mail($module, $key, $to, $language, $params, $from, $send);
if ($result['result'] == TRUE) {
drupal_set_message(t('Your message has been sent.'));
}
else {
drupal_set_message(t('There was a problem sending your message and it was not sent.'), 'error');
}
}