You are here

function mimemail_example_mail in Mime Mail 8

Same name and namespace in other branches
  1. 7 modules/mimemail_example/mimemail_example.module \mimemail_example_mail()

Implements hook_mail().

File

modules/mimemail_example/mimemail_example.module, line 30
Hook implementations for the Mime Mail Example module.

Code

function mimemail_example_mail($key, &$message, $params) {

  // The $params array holds the values entered on the ExampleForm, stored
  // with the same structure as the $form array. We need to copy these values
  // to the appropriate place in the $message so that they get used when
  // sending the email.
  $message['from'] = isset($params['headers']['From']) ? $params['headers']['From'] : NULL;

  // Strip newline characters from e-mail subjects.
  $message['subject'] = isset($params['subject']) ? str_replace([
    "\r\n",
    "\r",
    "\n",
  ], ' ', $params['subject']) : NULL;
  $message['body'][] = $params['body'];
}