How to change email address in Reply-To header of Wordpress email

Viewed 2136

Hi I am using Wordpress on Bluehost. I want to change the Reply-to header of the emails sent. I am using the filter 'wp_mail' to filter the 'headers' array described in the wp_mail filter documentation of the wp codex. Here is my code, showing the function definition, and the add_filter() call:

function sp_reply_to($args) {
 $args['headers'] = array('Reply-To: Name <name@domain.com');
 return $args;
}
add_filter ( 'wp_mail', 'sp_reply_to');`

However, I don't see any changes happening to the Reply-To:, the name and email are not set.

Any ideas what could be going wrong? Is there a way to for sure override perhaps any plugin that could be setting the Reply-To.

Thanks

2 Answers

Yes, It's also worked for me with this code.

function reply_to($args) {
    $args['headers'] = array('Reply-To: Name <name@domain.com>');
    return $args;
}
add_filter ( 'wp_mail', 'reply_to');
Related