On this page
function contact_site_form_submit
contact_site_form_submit($form, &$form_state)
Form submission handler for contact_site_form().
See also
File
- modules/contact/contact.pages.inc, line 133
- Page callbacks for the Contact module.
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'] = '';
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!contact!contact.pages.inc/function/contact_site_form_submit/7.x