You are here

function mail_safety_cron in Mail Safety 7

Implements hook_cron().

File

./mail_safety.module, line 303
The core Mail Safety module file

Code

function mail_safety_cron() {

  // Queue Mail Safety mails older than the expiration setting to be deleted.
  $expire = variable_get('mail_safety_mail_expire', 0);
  if (!empty($expire)) {
    $mail_ids = db_select('mail_safety_dashboard', 'msd')
      ->fields('msd', array(
      'mail_id',
    ))
      ->condition('sent', REQUEST_TIME - $expire, '<=')
      ->execute()
      ->fetchCol();
    if (!empty($mail_ids)) {
      $queue = DrupalQueue::get('mail_safety_expire_mails');
      foreach ($mail_ids as $mail_id) {
        $queue
          ->createItem($mail_id);
      }
    }
  }
}