You are here

function rules_action_mail_to_user in Rules 6

Action Implementation: Send a mail to a user.

Related topics

1 call to rules_action_mail_to_user()
rules_action_mail in rules/modules/system.rules.inc
Action Implementation: rules_action_mail This action makes use of the rules_action_mail_to_user action implementation.

File

rules/modules/system.rules.inc, line 109
rules integration for the system module

Code

function rules_action_mail_to_user($user, $settings) {

  // We also handle $settings['to'] if it's set.
  $to = isset($settings['to']) ? str_replace(array(
    "\r",
    "\n",
  ), '', $settings['to']) : $user->mail;
  $from = $settings['from'] ? str_replace(array(
    "\r",
    "\n",
  ), '', $settings['from']) : NULL;
  $message = drupal_mail('rules', 'rules_action_mail', $to, language_default(), $settings, $from);
  if ($message['result']) {
    watchdog('rules', 'Successfully sent email to %recipient', array(
      '%recipient' => $to,
    ));
  }
}