Skip to content

Instantly share code, notes, and snippets.

@GwynethLlewelyn
Created September 21, 2022 14:13
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 GwynethLlewelyn/521fb9d6c3137ce11cc7c2ed7e48b925 to your computer and use it in GitHub Desktop.
Save GwynethLlewelyn/521fb9d6c3137ce11cc7c2ed7e48b925 to your computer and use it in GitHub Desktop.
WordPress plugin to Change Email From Admin Address
<?php
/*
Plugin Name: Change Email From Admin Address
Description: A way to get rid of email coming from the wrong address that will cause problems with spam filters.
Author: Clifford Paulick
Version: 1.0
Author URI: https://wpmudev.com/blog/wordpress-email-settings/
*/
/*
The default email address for the 'core' issues (plugin/theme changes/updates, etc.) in WordPress is simply <wordpress@full-name-of-your-wp-installation.tld>.
This is built-in, we cannot change it from any page or configuration option.
However, like everything else in WordPress, you _can_ add a filter/hook to change it: `wp_mail_from`!
The most practical way is to place the code below inside a file called `change-email-from-admin-address.php` and drop it under the Must-Use Plugins folder (`./wp-content/mu-plugins`).
That way, it won't be overwritten by anything (you can freely change themes and/or `config.php` options), and will remain operational!
*/
/* enter the full email address you want displayed */
/* from http://miloguide.com/filter-hooks/wp_mail_from/ */
function xyz_filter_wp_mail_from( $email )
{
return "my@valid-email-address.tld";
}
add_filter( "wp_mail_from", "xyz_filter_wp_mail_from" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment