How to change WordPress default email’s From name and address

You are probably reading this post because have already noticed, that every time someone submitted a comment on your blog, signed up as a user or did anything that required WordPress to generate and send an email, by default the “From Name” in that message appeared as “WordPress” and “From” address was “wordpress@your-domain.com”.

If this is not the way you want it – read on, as there is an easy way of customising both these fields.

So how can you change these WordPress default email settings for From Name and From address.

There are two ways of doing it without touching WordPress Core file:

  1. You can install a WordPress plugin which I made – “GNA Change Mail Sender
  2. Add filter to functions.php file.

The second option is my favourite because I prefer to keep all my tweaks in one functions.php file as later I can easily reuse them on another project.

So how do we do this?

First of all you need to find and open functions.php file – it should be in your activated theme folder.

Open it and either at the beginning or the end (as you prefer) – paste the following code:

add_filter( 'wp_mail_from', 'filter_wp_mail_from' );
add_filter( 'wp_mail_from_name', 'filter_wp_mail_from_name' );
function filter_wp_mail_from( $original_email_address ) {
	//Make sure the email is from the same domain 
	//as your website to avoid being marked as spam.
	return 'webmaster@mydomainname.com';
}

public function filter_wp_mail_from_name( $original_email_from  ) {
	return 'WordPress Email System';
}

Obviously you have to replace ‘webmaster@mydomainname.com’ with your actual address, and ‘WordPress Email System’ with the name that you want to appear as From Name on all messages.

Now, save the file and upload it.

These filters will simply override default WordPress email settings.

I hope one of these three solutions worked for you, share and enjoy.

Views (35)

Share on Facebook0Share on Google+0Share on LinkedIn0Tweet about this on TwitterEmail this to someonePrint this page
[Total: 1    Average: 5/5]

Leave a Reply

Your email address will not be published. Required fields are marked *

15 + sixteen =