You are here

simplenews_statistics_bounce.module in Simplenews Statistics 7

Same filename and directory in other branches
  1. 7.2 simplenews_statistics_bounce/simplenews_statistics_bounce.module

Integrates Bounce and Simplenews modules.

File

simplenews_statistics_bounce/simplenews_statistics_bounce.module
View source
<?php

/**
 * @file
 * Integrates Bounce and Simplenews modules.
 */

/**
 * Implements hook_bounce_mails_blocked().
 */
function simplenews_statistics_bounce_bounce_mails_blocked($mails) {

  // Filter out all email addresses that do not have a simplenews subscription.
  $conditions = array(
    'mail' => $mails,
  );
  $subscribers = simplenews_subscriber_load_multiple(array(), $conditions);

  // Remove all blocked emails from newsletter subscriptions.
  foreach ($subscribers as $subscriber) {
    $mail = $subscriber->mail;
    foreach ($subscriber->newsletter_subscription as $newsletter_id => $value) {
      simplenews_unsubscribe_user($mail, $newsletter_id, FALSE, 'bounce');
    }

    // Notify the Drupal watchdog.
    watchdog('simplenews_statistics_bounce', 'Unsubscribed blocked email address %mail from all newsletters.', array(
      '%mail' => $mail,
    ));
  }
}

Functions

Namesort descending Description
simplenews_statistics_bounce_bounce_mails_blocked Implements hook_bounce_mails_blocked().