Change WordPress Default Email From Name And Address

Change WordPress Default Email From Name And Address

By default, WordPress uses the from name “WordPress” and address “[email protected]” when it sends notifications to users. It isn’t convenient and you might want to change it into your Blog name or something like that. This tutorial will show you how to do this just with some simple code.

Open the functions.php file of your theme and paste the following code into it:

add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');

function new_mail_from($old) {
 return '[email protected]';
}
function new_mail_from_name($old) {
 return 'Your Blog Name';
}

Change the email address and from name to anything you want, then save file.

From now, when sends notifications (for example, when new user registers), you can see the from address looks like: Your Blog Name <[email protected]>.

Changing WordPress default email from name and address is simple, but it’s useful. I wonder why WordPress doesn’t use the default admin’s information to do that. Hope in the future, WordPress will make it easy to adjust these information. But for now, you can use this small hack for this purpose.

12 thoughts on “Change WordPress Default Email From Name And Address

  1. This is exactly what I was looking for, because I didn’t want to modify WordPress’ source files (your changes get clobbered if/when you upgrade WordPress). However, IMHO, you want to avoid making changes to the theme’s functions.php file for the same reason. The filters you mention can be added to any file that gets included by WordPress, and it would seem the best one to use for this is wp-config.php. You can put your lines of code right at the end (after the require_once(ABSPATH . ‘wp-settings.php’) line), and it works like a charm. The benefit is that your config file is guaranteed to remain untouched no matter what other parts of WordPress you add/remove/upgrade.

    1. Actually writing code into “wp-config.php” is not a good choice. You better create your own functionality plugin (a plugin which has only code for current site), or better – must use plugin.

  2. If you want to get the default site email address and the site title just copy/paste in functions.php


    /**
    * change WordPress default FROM email address
    **/
    add_filter('wp_mail_from', 'new_mail_from');
    add_filter('wp_mail_from_name', 'new_mail_from_name');
    function new_mail_from($old) {
    $email = get_option( 'admin_email' );
    return $email;
    }
    function new_mail_from_name($old) {
    $site_name = get_option( 'blogname');
    return $site_name;
    }

  3. This is what I was looking for, now I can add my own email address for notifications. And it will not go into spam any more. thanks a lot.

  4. I have a large problem with this- it does change the outbound email- but I have web forms on my site and it changes the from part to the new email address (so when I click reply I am sending to myself) I need it to only change the emails being sent- and not incoming emails from my web forms- I have tried editing pluggable.php but it makes no change

    1. This technique works for default emails sent by WordPress. If you’re using a contact form, you probably need to check with the contact form settings (or the plugin settings).

    2. most of the change your email plugins have 2 options Name and email and thats all- I found the plugin that works
      https://wordpress.org/plugins/personal-email/ which is as simple as it gets- no settings upload and activate and it uses the email from the settings page and the website name as the name works with the contact forms- so anyone using gravity forms for example or contact Bank plugin should check it out

Comments are closed.

Newsletter

Subscribe to our newsletter to receive news and tutorials about WordPress and web development.

Meta Box - The most lightweight yet powerful WordPress custom fields plugin Get It Now