# Add a Reply-To Header to Outgoing Emails

> Adds the site admin address as Reply-To on emails that do not set one, so replies to no-reply senders reach a real inbox.

- Type: PHP
- Runs: Run everywhere
- Category: [Email](https://wpide.com/library/category/email/)
- Tags: email, reply-to, headers
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/email-reply-to-admin/

## Code

```php
add_filter( 'wp_mail', function ( $args ) {
    $reply_to = (string) get_option( 'admin_email' );
    $headers  = isset( $args['headers'] ) ? $args['headers'] : array();

    if ( ! is_array( $headers ) ) {
        $headers = '' === trim( (string) $headers ) ? array() : explode( "\n", str_replace( "\r\n", "\n", (string) $headers ) );
    }

    foreach ( $headers as $header ) {
        if ( 0 === stripos( trim( $header ), 'reply-to:' ) ) {
            return $args;
        }
    }

    if ( is_email( $reply_to ) ) {
        $headers[]       = 'Reply-To: ' . $reply_to;
        $args['headers'] = $headers;
    }

    return $args;
} );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Add a Reply-To Header to Outgoing Emails" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
