function email_mail_page_form_submit in Email Field 7
Same name and namespace in other branches
- 5 email.module \email_mail_page_form_submit()
- 6.2 email.module \email_mail_page_form_submit()
- 6 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 411 - Module file for the email module, which creates a email address field.
Code
function email_mail_page_form_submit($form, &$form_state) {
$object_type = $form_state['values']['object_type'];
$object_id = $form_state['values']['object_id'];
$field_name = $form_state['values']['field_name'];
$email = $form_state['values']['email'];
// Load entity
$objects = entity_load($object_type, array(
$object_id,
));
$object = $objects[$object_id];
$object_info = entity_get_info($object_type);
// 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['object'] = $object;
$params['subject'] = $form_state['values']['subject'];
$params['name'] = $form_state['values']['name'];
$params['message'] = $form_state['values']['message'];
$path = "";
if (isset($object_info['path callback']) && function_exists($object_info['path callback'])) {
$path = $object_info['path callback']($object);
}
$params['url'] = url($path, 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', '%name-from sent an e-mail at %form.', array(
'%name-from' => $form_state['values']['name'],
'%form' => url($_GET['q'], array(
'absolute' => TRUE,
)),
));
drupal_set_message(t('Your message has been sent.'));
$form_state['redirect'] = $path;
}