Skip to content

Instantly share code, notes, and snippets.

@schorschii
Last active January 30, 2024 15:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schorschii/51c966a0eb035048427fe674abc5c84a to your computer and use it in GitHub Desktop.
Save schorschii/51c966a0eb035048427fe674abc5c84a to your computer and use it in GitHub Desktop.
Simple WordPress plugin to set the "envelope sender" correctly, so that e.g. Gmail accepts them. Just create a folder "wp-content/plugins/fix-mail-sender" and put this file there. Don't forget to activate the plugin and enjoy. Note: if you are on Hetzner, you need to create a mailbox "wordpress@yourdomain.tld" too to make it work. Don't ask why.
<?php
/**
* Plugin Name: Fix Mail Sender
* Plugin URI: https://georg-sieber.de
* Description: Sets the envelope sender correctly to the "From" header address to enable mail delivery to Gmail from managed webservers.
* Version: 1.0
* Author: Georg Sieber
* Author URI: https://georg-sieber.de
* License: free
*/
function fixEnvelopeSender($phpmailer) {
$phpmailer->Sender = $phpmailer->From;
}
add_action( 'phpmailer_init', 'fixEnvelopeSender' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment