You are here

function email_contact_mail in Email Contact 7

Same name and namespace in other branches
  1. 8 email_contact.module \email_contact_mail()

Implements hook_mail().

File

./email_contact.module, line 481
File name: email_contact.module.

Code

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

      // Compose the body.
      if (module_exists('token')) {
        $message['body'][] = token_replace($params['default_message']);
      }
      else {
        $message['body'][] = $params['default_message'];
      }
      $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']);
      $message['headers']['Reply-to'] = $message['headers']['From'];
      $message['headers']['From'] = $message['headers']['Sender'] = $message['headers']['Return-Path'] = variable_get('site_mail', ini_get('sendmail_from'));
      break;
  }
}