You are here

function simplenews_confirmation_send in Simplenews 7.2

Same name and namespace in other branches
  1. 7 simplenews.module \simplenews_confirmation_send()

Send a confirmation mail.

Either sends a mail immediatly or collects them for a combined mail.

Parameters

$action: The confirmation type, either subscribe or unsubscribe.

$subscriber: The subscriber object.

$newsletter: The newsletter object.

2 calls to simplenews_confirmation_send()
simplenews_subscribe in ./simplenews.module
Subscribe a user to a newsletter or send a confirmation mail.
simplenews_unsubscribe in ./simplenews.module
Unsubscribe a user from a mailing list or send a confirmation mail.

File

./simplenews.module, line 3078
Simplenews node handling, sent email, newsletter block and general hooks

Code

function simplenews_confirmation_send($action, $subscriber, $newsletter) {

  // Check if confirmation should be sent immediatly or grouped.
  if (simplenews_confirmation_combine()) {
    simplenews_confirmation_add_combined($action, $subscriber, $newsletter);
  }
  else {

    // Send confirmation email to user to complete (un)subscription.
    // Confirmation mail is in the user preferred language which is by default the
    // language_default().
    module_load_include('inc', 'simplenews', 'includes/simplenews.mail');
    $params['from'] = _simplenews_set_from();
    $params['context']['newsletter'] = $newsletter;
    $params['context']['simplenews_subscriber'] = $subscriber;
    drupal_mail('simplenews', $action, $subscriber->mail, $subscriber->language, $params, $params['from']['address']);
  }
}