You are here

function email_mail in Email Field 6

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

Implementation of hook_mail()

File

./email.module, line 423

Code

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

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

      // Tidy up the body:
      foreach ($msg as $index_key => $value) {
        $msg[$index_key] = wordwrap($value);
      }

      // Prepare the body:
      $message['body'] = implode("\n\n", $msg);
      $message['subject'] = t('[@title] @subject', array(
        '@title' => preg_replace("/\r|\n/", '', $node->title),
        '@subject' => $params['subject'],
      ), $language->language);
      break;
  }
}