You are here

function email_mail in Email Field 7

Same name and namespace in other branches
  1. 6 email.module \email_mail()

Implements hook_mail().

File

./email.module, line 452
Module file for the email module, which creates a email address field.

Code

function email_mail($key, &$message, $params) {
  $language = $message['language'];
  switch ($key) {
    case 'contact':

      // Compose the body:
      $message['body'][] = t('@name sent a message using the contact form at @url.', array(
        '@name' => $params['name'],
        '@url' => $params['url'],
      ), array(
        'langcode' => $language->language,
      ));
      $message['body'][] = $params['message'];
      $message['subject'] = "";

      // Include the title of the entity, if one exists
      $object = $params['object'];
      if (isset($object->title) && !empty($object->title)) {
        $message['subject'] = "[" . check_plain(preg_replace("/\r|\n/", '', $object->title)) . "]";
      }
      $message['subject'] .= " " . check_plain($params['subject']);
      break;
  }
}