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

Form submission handler for contact_personal_form().

See also



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


function contact_personal_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'];

  // 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['recipient']->mail;
  $from = $values['sender']->mail;

  // Send the email in the requested user language.
  backdrop_mail('contact', 'user_mail', $to, user_preferred_language($values['recipient']), $values, $from);

  // Send a copy if requested, using current page language.
  if ($values['copy']) {
    backdrop_mail('contact', 'user_copy', $from, $language, $values, $from);

  $config = config('contact.settings');
  flood_register_event('contact', $config->get('contact_threshold_window'));
  watchdog('mail', '%sender-name (@sender-from) sent %recipient-name an email.', 
    '%sender-name' => $values['name'],
    '@sender-from' => $from,
    '%recipient-name' => $values['recipient']->name,

  // Jump to the contacted user's profile page.
  backdrop_set_message(t('Your message has been sent.'));
  $form_state['redirect'] = user_access('access user profiles') ? 'user/' . $values['recipient']->uid : '';