Skip to content

Instantly share code, notes, and snippets.

@jnicol
Created May 5, 2023 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnicol/299b4e66dd2208892611de34ed07a601 to your computer and use it in GitHub Desktop.
Save jnicol/299b4e66dd2208892611de34ed07a601 to your computer and use it in GitHub Desktop.
Fix WordPress wp_mail Return Path header, which is used for SPF checks, so that it matches From domain.
<?php
/*
Plugin Name: Email Return Path Fix
Author: Abdussamad Abdurrazzaq
Author URI: https://abdussamad.com/archives/567-Fixing-the-WordPress-Email-Return-Path-Header.html
*/
class email_return_path {
function __construct() {
add_action( 'phpmailer_init', array( $this, 'fix' ) );
}
function fix( $phpmailer ) {
$phpmailer->Sender = $phpmailer->From;
}
}
new email_return_path();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment