2 * Implements hook_mail().
4 function {{ machine_name }}_mail($key, &$message, $params) {
5 $account = $params['account'];
6 $context = $params['context'];
8 '%site_name' => variable_get('site_name', 'Drupal'),
9 '%username' => format_username($account),
11 if ($context['hook'] == 'taxonomy') {
12 $entity = $params['entity'];
13 $vocabulary = taxonomy_vocabulary_load($entity->vid);
15 '%term_name' => $entity->name,
16 '%term_description' => $entity->description,
17 '%term_id' => $entity->tid,
18 '%vocabulary_name' => $vocabulary->name,
19 '%vocabulary_description' => $vocabulary->description,
20 '%vocabulary_id' => $vocabulary->vid,
24 // Node-based variable translation is only available if we have a node.
25 if (isset($params['node'])) {
26 $node = $params['node'];
29 '%node_url' => url('node/' . $node->nid, array('absolute' => TRUE)),
30 '%node_type' => node_type_get_name($node),
31 '%title' => $node->title,
32 '%teaser' => $node->teaser,
33 '%body' => $node->body,
36 $subject = strtr($context['subject'], $variables);
37 $body = strtr($context['message'], $variables);
38 $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
39 $message['body'][] = drupal_html_to_text($body);