[Documentation](https://groundhogg.io/documentation/) » [Filter Hooks](https://groundhogg.io/documentation/#doc-filter-hooks)

# groundhogg/email/to

Published Wednesday, June 10, 2026 · Last updated Wednesday, June 10, 2026

Filters the `To` email address just before a message is sent. Use this to redirect emails — for example, to route all sends through a test inbox in staging environments.

```

apply_filters( 'groundhogg/email/to', $to, $contact, $email );
```

You will receive the recipient email address string, the `Contact` object, and the `Email` object.

## Example

```

add_filter( 'groundhogg/email/to', 'my_extension_redirect_in_staging', 10, 3 );

/**
 * Redirect all emails to a test inbox on staging.
 *
 * @param string               $to
 * @param \Groundhogg\Contact $contact
 * @param \Groundhogg\Email   $email
 *
 * @return string
 */
function my_extension_redirect_in_staging( $to, $contact, $email ) {
    if ( defined( 'WP_ENV' ) && WP_ENV === 'staging' ) {
        return 'staging-inbox@example.com';
    }

    return $to;
}
```
