You are here

function contact_mail in Drupal 6

Same name and namespace in other branches
  1. 8 core/modules/contact/contact.module \contact_mail()
  2. 7 modules/contact/contact.module \contact_mail()
  3. 9 core/modules/contact/contact.module \contact_mail()
  4. 10 core/modules/contact/contact.module \contact_mail()

Implementation of hook_mail().

File

modules/contact/contact.module, line 185
Enables the use of personal and site-wide contact forms.

Code

function contact_mail($key, &$message, $params) {
  $language = $message['language'];
  switch ($key) {
    case 'page_mail':
    case 'page_copy':
      $contact = $params['contact'];
      $message['subject'] .= t('[!category] !subject', array(
        '!category' => $contact['category'],
        '!subject' => $params['subject'],
      ), $language->language);
      $message['body'][] = t("!name sent a message using the contact form at !form.", array(
        '!name' => $params['name'],
        '!form' => url($_GET['q'], array(
          'absolute' => TRUE,
          'language' => $language,
        )),
      ), $language->language);
      $message['body'][] = $params['message'];
      break;
    case 'page_autoreply':
      $contact = $params['contact'];
      $message['subject'] .= t('[!category] !subject', array(
        '!category' => $contact['category'],
        '!subject' => $params['subject'],
      ), $language->language);
      $message['body'][] = $contact['reply'];
      break;
    case 'user_mail':
    case 'user_copy':
      $user = $params['user'];
      $account = $params['account'];
      $message['subject'] .= '[' . variable_get('site_name', 'Drupal') . '] ' . $params['subject'];
      $message['body'][] = "{$account->name},";
      $message['body'][] = t("!name (!name-url) has sent you a message via your contact form (!form-url) at !site.", array(
        '!name' => $user->name,
        '!name-url' => url("user/{$user->uid}", array(
          'absolute' => TRUE,
          'language' => $language,
        )),
        '!form-url' => url($_GET['q'], array(
          'absolute' => TRUE,
          'language' => $language,
        )),
        '!site' => variable_get('site_name', 'Drupal'),
      ), $language->language);
      $message['body'][] = t("If you don't want to receive such e-mails, you can change your settings at !url.", array(
        '!url' => url("user/{$account->uid}", array(
          'absolute' => TRUE,
          'language' => $language,
        )),
      ), $language->language);
      $message['body'][] = t('Message:', NULL, $language->language);
      $message['body'][] = $params['message'];
      break;
  }
}