function _subscriptions_mail_send in Subscriptions 6
Same name and namespace in other branches
- 5.2 subscriptions_mail.module \_subscriptions_mail_send()
- 7 subscriptions_mail.cron.inc \_subscriptions_mail_send()
- 2.0.x subscriptions_mail/subscriptions_mail.cron.inc \_subscriptions_mail_send()
Send the notification by mail.
1 call to _subscriptions_mail_send()
- _subscriptions_mail_cron in ./
subscriptions_mail.cron.inc - Implementation of hook_cron().
File
- ./
subscriptions_mail.cron.inc, line 278 - Subscriptions module mail gateway (cron functions).
Code
function _subscriptions_mail_send($mailkey, $name, $to, $subject, $body, $from, $uid, $send_intervals) {
global $user;
if (variable_get('subscriptions_mail_trash_silently', 0)) {
// Block notification mail; useful for staging and development servers.
return;
}
$mail_success = drupal_mail('subscriptions_mail', $mailkey, $to, user_preferred_language($user), array(
'account' => $user,
'object' => NULL,
'context' => array(
'recipient' => $to,
'subject' => $subject,
'message' => $body,
),
), $from, TRUE);
$to = check_plain($to);
$watchdog = 'watchdog';
$watchdog_params = array(
'@name' => $name,
'@to' => $to,
'%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 for @name at @to', $watchdog_params), NULL);
}
foreach ($send_intervals as $send_interval) {
db_query("UPDATE {subscriptions_last_sent} SET last_sent = %d WHERE uid = %d AND send_interval = %d", time(), $uid, $send_interval);
if (!db_affected_rows()) {
@db_query("INSERT INTO {subscriptions_last_sent} (uid, send_interval, last_sent) VALUES(%d, %d, %d)", $uid, $send_interval, time());
}
}
}
else {
$watchdog('subscriptions', t('error mailing notification for @name at @to', $watchdog_params), NULL, WATCHDOG_ERROR);
}
}