You are here

function simplenews_build_subscribe_mail in Simplenews 7.2

Same name and namespace in other branches
  1. 7 includes/simplenews.mail.inc \simplenews_build_subscribe_mail()

Build subject and body of the subscribe confirmation email.

Parameters

array $message: Message array as used by hook_mail().

array $params: Parameter array as used by hook_mail().

1 call to simplenews_build_subscribe_mail()
simplenews_mail in ./simplenews.module
Implements hook_mail().

File

includes/simplenews.mail.inc, line 831
Simplenews email send and spool handling

Code

function simplenews_build_subscribe_mail(&$message, $params) {
  $context = $params['context'];
  $langcode = $message['language'];

  // Use formatted from address "name" <mail_address>
  $message['headers']['From'] = $params['from']['formatted'];
  $message['subject'] = simplenews_subscription_confirmation_text('subscribe_subject', $langcode);
  $message['subject'] = token_replace($message['subject'], $context, array(
    'sanitize' => FALSE,
  ));
  if (simplenews_user_is_subscribed($context['simplenews_subscriber']->mail, $context['newsletter']->newsletter_id)) {
    $body = simplenews_subscription_confirmation_text('subscribe_subscribed', $langcode);
  }
  else {
    $body = simplenews_subscription_confirmation_text('subscribe_unsubscribed', $langcode);
  }
  $message['body'][] = token_replace($body, $context, array(
    'sanitize' => FALSE,
  ));
}