function contact_site_form_submit
Form submission handler for contact_site_form().
See also
File
-
modules/
contact/ contact.pages.inc, line 133
Code
function contact_site_form_submit($form, &$form_state) {
global $user, $language;
$values = $form_state['values'];
$values['sender'] = clone $user;
$values['sender']->name = $values['name'];
$values['sender']->mail = $values['mail'];
$values['category'] = contact_load($values['cid']);
// Save the anonymous user information to a cookie for reuse.
if (!$user->uid) {
user_cookie_save(array_intersect_key($values, array_flip(array(
'name',
'mail',
))));
}
// Get the to and from e-mail addresses.
$to = $values['category']['recipients'];
$from = $values['sender']->mail;
// Send the e-mail to the recipients using the site default language.
drupal_mail('contact', 'page_mail', $to, language_default(), $values, $from);
// If the user requests it, send a copy using the current language.
if ($values['copy']) {
drupal_mail('contact', 'page_copy', $from, $language, $values, $from);
}
// Send an auto-reply if necessary using the current language.
if ($values['category']['reply']) {
drupal_mail('contact', 'page_autoreply', $from, $language, $values, $to);
}
flood_register_event('contact', variable_get('contact_threshold_window', 3600));
watchdog('mail', '%sender-name (@sender-from) sent an e-mail regarding %category.', array(
'%sender-name' => $values['name'],
'@sender-from' => $from,
'%category' => $values['category']['category'],
));
// Jump to home page rather than back to contact page to avoid
// contradictory messages if flood control has been activated.
drupal_set_message(t('Your message has been sent.'));
$form_state['redirect'] = '';
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.