Chris@0: /** Chris@0: * Implements hook_mail(). Chris@0: */ Chris@0: function {{ machine_name }}_mail($key, &$message, $params) { Chris@0: $account = $params['account']; Chris@0: $context = $params['context']; Chris@0: $variables = array( Chris@0: '%site_name' => variable_get('site_name', 'Drupal'), Chris@0: '%username' => format_username($account), Chris@0: ); Chris@0: if ($context['hook'] == 'taxonomy') { Chris@0: $entity = $params['entity']; Chris@0: $vocabulary = taxonomy_vocabulary_load($entity->vid); Chris@0: $variables += array( Chris@0: '%term_name' => $entity->name, Chris@0: '%term_description' => $entity->description, Chris@0: '%term_id' => $entity->tid, Chris@0: '%vocabulary_name' => $vocabulary->name, Chris@0: '%vocabulary_description' => $vocabulary->description, Chris@0: '%vocabulary_id' => $vocabulary->vid, Chris@0: ); Chris@0: } Chris@0: Chris@0: // Node-based variable translation is only available if we have a node. Chris@0: if (isset($params['node'])) { Chris@0: $node = $params['node']; Chris@0: $variables += array( Chris@0: '%uid' => $node->uid, Chris@0: '%node_url' => url('node/' . $node->nid, array('absolute' => TRUE)), Chris@0: '%node_type' => node_type_get_name($node), Chris@0: '%title' => $node->title, Chris@0: '%teaser' => $node->teaser, Chris@0: '%body' => $node->body, Chris@0: ); Chris@0: } Chris@0: $subject = strtr($context['subject'], $variables); Chris@0: $body = strtr($context['message'], $variables); Chris@0: $message['subject'] .= str_replace(array("\r", "\n"), '', $subject); Chris@0: $message['body'][] = drupal_html_to_text($body); Chris@0: }