You are here

function _auto_expire_notify in Auto Expire 5

Same name and namespace in other branches
  1. 7 auto_expire.module \_auto_expire_notify()
2 calls to _auto_expire_notify()
_auto_expire_notify_expired in ./auto_expire.module
_auto_expire_notify_warning in ./auto_expire.module

File

./auto_expire.module, line 430

Code

function _auto_expire_notify($nid, $mailkey, $subject, $body, $args) {
  if (!empty($subject)) {
    $result = db_query('SELECT u.mail FROM {users} u, {node} n WHERE n.nid = %d AND n.uid = u.uid AND u.status=1 AND u.uid>0', $nid);
    if ($result) {
      $userEmail = db_result($result);
      if ($userEmail) {
        $subject = t($subject, $args);
        $body = t($body, $args);
        $bcc = trim(variable_get(AUTO_EXPIRE_EMAIL . 'bcc', ''));
        if ($bcc == '') {
          $sent = drupal_mail($mailkey, $userEmail, $subject, $body);
        }
        else {
          $headers['Bcc'] = $bcc;
          $sent = drupal_mail($mailkey, $userEmail, $subject, $body, NULL, $headers);
        }
        if (!$sent) {
          watchdog('auto_expire', 'Could not send notification email to: ' . $userEmail, WATCHDOG_ERROR);
        }
      }
    }
  }
}