You are here

function _inactive_user_mail in Inactive User 5

Same name and namespace in other branches
  1. 6 inactive_user.module \_inactive_user_mail()
  2. 7 inactive_user.module \_inactive_user_mail()

Wrapper for user_mail

1 call to _inactive_user_mail()
inactive_user_cron in ./inactive_user.module
Implementation of hook_cron

File

./inactive_user.module, line 425

Code

function _inactive_user_mail($subject, $message, $period, $user = NULL, $user_list = NULL) {
  global $base_url;
  if ($user_list) {
    $to = _inactive_user_admin_mail();
    $variables = array(
      '%period' => _format_interval($period),
      '%sitename' => variable_get('site_name', 'drupal'),
      '%siteurl' => $base_url,
      "%userlist" => $user_list,
    );
  }
  elseif (isset($user->uid)) {
    $to = $user->mail;
    $variables = array(
      '%username' => $user->name,
      '%useremail' => $user->mail,
      '%lastaccess' => empty($user->access) ? t('never') : format_date($user->access, 'custom', 'M d, Y'),
      '%period' => _format_interval($period),
      '%sitename' => variable_get('site_name', 'drupal'),
      '%siteurl' => $base_url,
    );
  }
  if ($to) {
    $from = variable_get('site_mail', ini_get('sendmail_from'));
    $headers = array(
      'Reply-to' => $from,
      'Return-path' => "<{$from}>",
      'Errors-to' => $from,
    );
    $recipients = explode(',', $to);
    foreach ($recipients as $recipient) {
      drupal_mail('inactive_user_email', trim($recipient), $subject, wordwrap(strtr($message, $variables), 80), $from, $headers);
    }
  }
}