function mimemail_rules_action_mail_to_user in Mime Mail 6
Implements action to send a mail to a user and to an arbitrary mail address.
1 call to mimemail_rules_action_mail_to_user()
- mimemail_rules_action_mail in includes/
mimemail.rules.inc - Implements action to send HTML mail.
File
- includes/
mimemail.rules.inc, line 40 - Rules actions for sending MIME-encoded e-mails.
Code
function mimemail_rules_action_mail_to_user($user, $settings) {
global $language;
$key = !empty($settings['key']) ? $settings['key'] : 'rules_action_mail';
// Set the sender name and from address.
if (empty($settings['from'])) {
$from = NULL;
}
else {
$from = array(
'name' => $settings['sender'],
'mail' => $settings['from'],
);
}
// If recipient field is empty, send it to given user object.
$to = empty($settings['to']) ? $user->mail : $settings['to'];
// Prepare the message but don't send.
$message = drupal_mail('mimemail', $key, $to, $language, $settings, $from, FALSE);
// Send the prepared message.
$message = mimemail($message['from'], $message['to'], $message['subject'], $message['body'], NULL, $message['headers'], $message['params']['plaintext'], $message['params']['attachments'], $message['id']);
if ($message['result']) {
if (!empty($settings['bcc'])) {
$to .= ", " . $settings['bcc'];
}
if (!empty($settings['cc'])) {
$to .= ", " . $settings['cc'];
}
watchdog('rules', 'HTML mail successfully sent to %recipient', array(
'%recipient' => $to,
));
}
}