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.
Opens WPIDE on
Code
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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.