function _ad_actions_send_email in Advertisement 6.3
Same name and namespace in other branches
- 6.2 actions/ad_actions.module \_ad_actions_send_email()
- 7 actions/ad_actions.module \_ad_actions_send_email()
2 calls to _ad_actions_send_email()
- ad_actions_cron in actions/
ad_actions.module - Implementation of hook_cron().
- ad_actions_send_email_action_after in actions/
ad_actions.module - Implementation of a configurable Drupal action. Schedules an email, sent before scheduled actions.
File
- actions/
ad_actions.module, line 436 - Enable ad triggers and actions.
Code
function _ad_actions_send_email($context) {
_ad_actions_normalize_context($context);
$params['from'] = variable_get('site_mail', ini_get('sendmail_from'));
$recipient = token_replace_multiple($context['recipient'], $context);
$params['subject'] = str_replace(array(
"\r",
"\n",
), '', token_replace_multiple($context['subject'], $context));
$params['body'] = token_replace_multiple($context['message'], $context);
// we allow multiple comma separated recipients
$recipients = explode(',', $recipient);
foreach ($recipients as $recipient) {
$recipient = trim($recipient);
if (isset($context['disable_notifications']) && $context['disable_notifications'] != '-1') {
$account = user_load(array(
'mail' => $recipient,
));
$field = $context['disable_notifications'];
if (!empty($account->{$field})) {
watchdog('action', 'Notifications to %recipient are disabled, notification not sent', array(
'%recipient' => $recipient,
));
continue;
}
}
if (drupal_mail('ad_actions', 'ad_actions_send_email', $recipient, language_default(), $params)) {
watchdog('action', 'Sent email to %recipient', array(
'%recipient' => $recipient,
));
}
else {
watchdog('error', 'Unable to send email to %recipient', array(
'%recipient' => $recipient,
));
}
}
}