function contact_personal_form_submit

Form submission handler for contact_personal_form().

See also

contact_personal_form_validate()

File

modules/contact/contact.pages.inc, line 269

Code

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 e-mail addresses.
    $to = $values['recipient']->mail;
    $from = $values['sender']->mail;
    // Send the e-mail in the requested user language.
    drupal_mail('contact', 'user_mail', $to, user_preferred_language($values['recipient']), $values, $from);
    // Send a copy if requested, using current page language.
    if ($values['copy']) {
        drupal_mail('contact', 'user_copy', $from, $language, $values, $from);
    }
    flood_register_event('contact', variable_get('contact_threshold_window', 3600));
    watchdog('mail', '%sender-name (@sender-from) sent %recipient-name an e-mail.', array(
        '%sender-name' => $values['name'],
        '@sender-from' => $from,
        '%recipient-name' => $values['recipient']->name,
    ));
    // Jump to the contacted user's profile page.
    drupal_set_message(t('Your message has been sent.'));
    $form_state['redirect'] = user_access('access user profiles') ? 'user/' . $values['recipient']->uid : '';
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.