Change the Default Admin Email for WordPress

Olivier R Dec 24, 2024 Configuration
How can I change the email address that gets notifications from my WordPress site?
What code snippet can I use to update the default admin email address in WordPress without using the dashboard?
Andy answered Dec 24, 2024

Method 1: Using WP-CLI

The quickest way to change the admin email using WP-CLI:

wp option update admin_email new-email@example.com

Method 2: Direct Database Update

Add this code to your theme's functions.php file or in a site-specific plugin:

add_action('init', 'change_admin_email');

function change_admin_email() {
    update_option('admin_email', 'new-email@example.com');
}

Method 3: Using WordPress Hooks

This code changes the admin email for all WordPress notifications. Add to functions.php:

add_filter('wp_mail_from', 'custom_wp_mail_from');
add_filter('wp_mail_from_name', 'custom_wp_mail_from_name');

function custom_wp_mail_from($email) {
    return 'new-email@example.com';
}

function custom_wp_mail_from_name($name) {
    return 'Your Site Name';
}

Method 4: Using Constants

Add these lines to wp-config.php before the "/* That's all, stop editing! */" line:

define('WP_MAIL_FROM', 'new-email@example.com');
define('WP_MAIL_FROM_NAME', 'Your Site Name');

Recommended Plugins

If you prefer using a plugin:

  1. WP Mail SMTP - Most popular option for managing WordPress emails
  2. Easy WP SMTP - Simple alternative with good configuration options

Important Notes

  • Replace 'new-email@example.com' with your desired email address
  • For Method 2 and 3, remember to back up your functions.php before making changes
  • After changing the admin email, test WordPress notifications to ensure they're working correctly
  • Some hosting providers may have restrictions on sending emails from specific domains