How do I modify email headers when using Rules to send mail? I'm using the Drupal 7 Rules module to trigger and send emails on specific events, but need to modify the email headers before the message is sent.

What would be the appropriate way to add 'reply-to' headers (as used in RFC 5322) to specific outgoing emails that are sent using the Drupal 7 Rules module?

The following works when using drupal_mail() but I do not see how to apply this hook when using Rules.

function hook_mail($key, &amp;$message, $params) {
    switch ($key) {
        case 'key_name_here':
            $message['Reply-to'] = $params['mail'];
            $message['subject'] = $params['subject'];
            $message['body'] = $params['body'];
            $message['headers']['Reply-To'] = $params['mail'];
            break;    
    }
}
// One note to the above script, lines 4 and 7 seem redundant and likely need work.
You can still use hook_mail, you just need to identify the key for the rule or rules you want to override. The key is set in the rules_action_mail() function $key = 'rules_action_mail_' . $name . '_' . $element-&gt;elementId(); where name is the rule name and element id is the numeric id for the rule. You need to make sure your custom module has a higher weight that the rules module in the system table of your database.