array( 'label' => t('Send templated e-mail.'), 'group' => t('System'), 'parameter' => array( 'to' => array( 'type' => 'text', 'label' => t('To'), 'description' => t('The e-mail address or addresses where the message will be sent to. The formatting of this string must comply with RFC 2822.'), ), 'subject' => array( 'type' => 'text', 'label' => t('Subject'), 'description' => t("The mail's subject."), ), 'message' => array( 'type' => 'text', 'label' => t('Message'), 'description' => t("The mail's message body."), ), 'from' => array( 'type' => 'text', 'label' => t('From'), 'description' => t("The mail's from address. Leave it empty to use the site-wide configured address."), 'optional' => TRUE, ), 'key' => array( 'type' => 'text', 'label' => t('Key'), 'description' => t("The key to use with HTMLMail's suggestion system. The template's module will be Rules."), ), ), 'base' => 'rules_action_htmlmail', 'access callback' => 'rules_system_integration_access', ), ); } /** * Action Implementation: Send templated e-mail. */ function rules_action_htmlmail($to, $subject, $message, $from = NULL, $key, $settings, RulesState $state, RulesPlugin $element) { $to = str_replace(array("\r", "\n"), '', $to); $from = !empty($from) ? str_replace(array("\r", "\n"), '', $from) : NULL; $key = check_plain($key); $params = array( 'subject' => $subject, 'body' => $message, 'action' => $element, 'state' => $state, ); $message = drupal_mail('htmlmail', $key, $to, language_default(), $params, $from); if ($message['result']) { watchdog('rules', 'Successfully sent email to %recipient', array('%recipient' => $to)); } } /** * @} */