function _subscriptions_mail_send in Subscriptions 7
Same name and namespace in other branches
- 5.2 subscriptions_mail.module \_subscriptions_mail_send()
- 6 subscriptions_mail.cron.inc \_subscriptions_mail_send()
- 2.0.x subscriptions_mail/subscriptions_mail.cron.inc \_subscriptions_mail_send()
Sends the notification by mail.
Parameters
$module:
$mailkey:
$name:
$to:
$from:
$uid:
$send_intervals:
$data:
Return value
bool|null
1 call to _subscriptions_mail_send()
- _subscriptions_mail_cron in ./
subscriptions_mail.cron.inc - Implementation of hook_cron().
File
- ./
subscriptions_mail.cron.inc, line 298 - Subscriptions module mail gateway (cron functions).
Code
function _subscriptions_mail_send($module, $mailkey, $name, $to, $from, $uid, $send_intervals, $data) {
global $user;
if (variable_get('subscriptions_mail_trash_silently', 0)) {
// Block notification mail; useful for staging and development servers.
return NULL;
}
$mail_success = drupal_mail($module, $mailkey, $to, user_preferred_language($user), array(
'data' => $data,
'account' => $user,
'object' => NULL,
), $from, TRUE);
$to = check_plain($to);
$watchdog = 'watchdog';
$watchdog_params = array(
'%name' => $name,
'!address' => "<a href='mailto:{$to}'>{$to}</a>",
'!result' => 'result',
'%result' => $mail_success['result'],
'!drupal_mail' => l('drupal_mail', 'http://api.drupal.org/api/search/7/drupal_mail'),
);
if (variable_get('subscriptions_watchall', 0)) {
$watchdog('subscriptions', t('Notification for %name (!address) passed on to !drupal_mail(), !result=[%result].', $watchdog_params), NULL, WATCHDOG_DEBUG);
}
if (!empty($mail_success['result'])) {
if (variable_get('subscriptions_watchgood', 1)) {
$watchdog('subscriptions', t('Notification sent to...'), NULL);
}
foreach ($send_intervals as $send_interval) {
db_merge('subscriptions_last_sent')
->key(array(
'uid' => $uid,
'send_interval' => $send_interval,
))
->fields(array(
'last_sent' => REQUEST_TIME,
))
->execute();
}
return TRUE;
}
$watchdog('subscriptions', t('Error e-mailing notification to %name (!address).', $watchdog_params), NULL, WATCHDOG_ERROR);
return FALSE;
}