1 contact.pages.inc contact_site_form_submit($form, &$form_state)

Form submission handler for contact_site_form().

See also



core/modules/contact/contact.pages.inc, line 138
Page callbacks for the Contact module.


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 email addresses.
  $to = $values['category']['recipients'];
  $from = $values['sender']->mail;

  // Send the email to the recipients using the site default language.
  backdrop_mail('contact', 'page_mail', $to, language_default(), $values, $from);

  // If the user requests it, send a copy using the current language.
  if ($values['copy']) {
    backdrop_mail('contact', 'page_copy', $from, $language, $values, $from);

  // Send an auto-reply if necessary using the current language.
  if ($values['category']['reply']) {
    backdrop_mail('contact', 'page_autoreply', $from, $language, $values, $to);

  $config = config('contact.settings');
  flood_register_event('contact', $config->get('contact_threshold_window'));
  watchdog('mail', '%sender-name (@sender-from) sent an email regarding %category.', 
    '%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.
  backdrop_set_message(t('Your message has been sent.'));
  $form_state['redirect'] = '';