function contact_mail_user_submit in Contact 6.2
Form submission handler for contact_mail_user().
See also
File
- ./
contact.pages.inc, line 267 - User page callbacks for the contact module.
Code
function contact_mail_user_submit($form, &$form_state) {
global $user, $language;
$values = $form_state['values'];
$values['sender'] = $user;
$values['sender']->name = $values['name'];
$values['sender']->mail = $values['mail'];
// Save the anonymous user information to a cookie for reuse.
if (!$user->uid) {
contact_cookie_save($values);
}
// 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');
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 : '';
}