# Match the Return-Path to the From Address

> Sets the envelope sender (Return-Path) of outgoing emails to the From address, which improves SPF alignment and deliverability on many hosts.

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

## Code

```php
add_action( 'phpmailer_init', function ( $phpmailer ) {
    if ( empty( $phpmailer->Sender ) && is_email( $phpmailer->From ) ) {
        $phpmailer->Sender = $phpmailer->From;
    }
} );
```

## Notes

Your From address domain must be allowed to send from the server (SPF record).

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Match the Return-Path to the From Address" 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/
