You are here

function email_mail_page_form_submit in Email Field 6

Same name and namespace in other branches
  1. 5 email.module \email_mail_page_form_submit()
  2. 6.2 email.module \email_mail_page_form_submit()
  3. 7 email.module \email_mail_page_form_submit()

Process the site-wide contact page form submission.

1 string reference to 'email_mail_page_form_submit'
email_mail_page_form in ./email.module
Contact form

File

./email.module, line 390

Code

function email_mail_page_form_submit($form, &$form_state) {
  $node = $form_state['values']['node'];
  $field_name = $form_state['values']['field_name'];
  $email = $form_state['values']['email'];

  // 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 = $form_state['values']['mail'];
  $params['node'] = $node;
  $params['subject'] = $form_state['values']['subject'];
  $params['name'] = $form_state['values']['name'];
  $params['message'] = $form_state['values']['message'];
  $params['url'] = url('node/' . $node->nid, array(
    'absolute' => TRUE,
  ));

  // Send the e-mail to the recipients:
  drupal_mail('email', 'contact', $email, language_default(), $params, $from);

  // Log the operation:
  flood_register_event('email');
  watchdog('mail', t('%name-from sent an e-mail at %form.', array(
    '%name-from' => theme('placeholder', $form_state['values']['name'] . " <{$from}>"),
    '%form' => url($_GET['q'], array(
      'absolute' => TRUE,
    )),
  )));

  // Update user:
  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'] = 'node/' . $node->nid;
}