diff --git a/modules/update/update.fetch.inc b/modules/update/update.fetch.inc index 470bb41..df3e711 100644 --- a/modules/update/update.fetch.inc +++ b/modules/update/update.fetch.inc @@ -171,7 +170,12 @@ function _update_cron_notify() { else { $target_language = $default_language; } - drupal_mail('update', 'status_notify', $target, $target_language, $params); + $message = drupal_mail('update', 'status_notify', $target, $target_language, $params); + // Track when the last mail was successfully sent to avoid sending + // too many e-mails. + if ($message['result']) { + variable_set('update_last_email_notification', time()); + } } } } diff --git a/modules/update/update.install b/modules/update/update.install index ba91b70..bfb56ae 100644 --- a/modules/update/update.install +++ b/modules/update/update.install @@ -22,6 +21,7 @@ function update_uninstall() { 'update_check_frequency', 'update_fetch_url', 'update_last_check', + 'update_last_email_notification', 'update_notification_threshold', 'update_notify_emails', ); diff --git a/modules/update/update.module b/modules/update/update.module index b6b595a..881adc8 100644 --- a/modules/update/update.module +++ b/modules/update/update.module @@ -300,6 +299,11 @@ function update_cron() { // configured update interval has elapsed. if (!_update_cache_get('update_available_releases') || ((time() - variable_get('update_last_check', 0)) > $interval)) { update_refresh(); + } + if ((time() - variable_get('update_last_email_notification', 0)) > $interval) { + // If configured time between notifications elapsed, send email about + // updates possibly available. + module_load_include('inc', 'update', 'update.fetch'); _update_cron_notify(); } }