You are here

function contact_mail_page_submit in Drupal 6

Same name and namespace in other branches
  1. 4 modules/contact.module \contact_mail_page_submit()
  2. 5 modules/contact/contact.module \contact_mail_page_submit()

Process the site-wide contact page form submission.

File

modules/contact/contact.pages.inc, line 118
User page callbacks for the contact module.

Code

function contact_mail_page_submit($form, &$form_state) {
  global $language;
  $values = $form_state['values'];

  // E-mail address of the sender: as the form field is a text field,
  // all instances of \r and \n have been automatically stripped from it.
  $from = $values['mail'];

  // Load category properties and save form values for email composition.
  $contact = contact_load($values['cid']);
  $values['contact'] = $contact;

  // Send the e-mail to the recipients using the site default language.
  drupal_mail('contact', 'page_mail', $contact['recipients'], 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 ($contact['reply']) {
    drupal_mail('contact', 'page_autoreply', $from, $language, $values, $contact['recipients']);
  }
  flood_register_event('contact');
  watchdog('mail', '%name-from sent an e-mail regarding %category.', array(
    '%name-from' => $values['name'] . " [{$from}]",
    '%category' => $contact['category'],
  ));
  drupal_set_message(t('Your message has been sent.'));

  // Jump to home page rather than back to contact page to avoid
  // contradictory messages if flood control has been activated.
  $form_state['redirect'] = '';
}