function contact_mail_page_submit in Drupal 5
Same name and namespace in other branches
- 4 modules/contact.module \contact_mail_page_submit()
- 6 modules/contact/contact.pages.inc \contact_mail_page_submit()
Process the site-wide contact page form submission.
File
- modules/
contact/ contact.module, line 504 - Enables the use of personal and site-wide contact forms.
Code
function contact_mail_page_submit($form_id, $form_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 = $form_values['mail'];
// Compose the body:
$message[] = t("!name sent a message using the contact form at !form.", array(
'!name' => $form_values['name'],
'!form' => url($_GET['q'], NULL, NULL, TRUE),
));
$message[] = $form_values['message'];
// Tidy up the body:
foreach ($message as $key => $value) {
$message[$key] = wordwrap($value);
}
// Load the category information:
$contact = db_fetch_object(db_query("SELECT * FROM {contact} WHERE cid = %d", $form_values['cid']));
// Format the category:
$subject = t('[!category] !subject', array(
'!category' => $contact->category,
'!subject' => $form_values['subject'],
));
// Prepare the body:
$body = implode("\n\n", $message);
// Send the e-mail to the recipients:
drupal_mail('contact-page-mail', $contact->recipients, $subject, $body, $from);
// If the user requests it, send a copy.
if ($form_values['copy']) {
drupal_mail('contact-page-copy', $from, $subject, $body, $from);
}
// Send an auto-reply if necessary:
if ($contact->reply) {
drupal_mail('contact-page-autoreply', $from, $subject, wordwrap($contact->reply), $contact->recipients);
}
// Log the operation:
flood_register_event('contact');
watchdog('mail', t('%name-from sent an e-mail regarding %category.', array(
'%name-from' => $form_values['name'] . " <{$from}>",
'%category' => $contact->category,
)));
// 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.
return '';
}