function token_actions_send_email_action in Token 6
Action callback to send a tokenized e-mail.
See also
token_actions_send_email_action_form()
token_actions_send_email_action_submit()
File
- ./
token_actions.module, line 68 - The Token Actions module.
Code
function token_actions_send_email_action($object, $context) {
token_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);
if (drupal_mail('token_actions', 'action_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,
));
}
}