Changing the WordPress notification ‘From’ address

When WordPress sends out notification emails, it uses very generic and poorly branded ‘From’ headers. You may notice all your WordPress notifications come from your theme as wordpress@yoursite.com; wouldn’t it be nice if they came from you@yoursite.com?

Now that’s not WordPress’s fault at all, it is our job as developers to make sure we brand that as well as the rest of the site.

Here is a very basic default you can include in the functions.php file of your theme:

add_filter('wp_mail_from', 'my_fromemail');
function my_fromemail($email) { return get_option('admin_email'); }

add_filter('wp_mail_from_name', 'my_fromname');
function my_fromname($email) { return get_option('blogname'); }

 

wp_mail_from should always return an email address: you@yoursite.com or Firstname Lastname <you@yoursite.com>.

wp_mail_from_name should always return a name string: Firstname Lastname.

Feel free to change the return values if you want to customize it even further!

Tags:
fold-left fold-right
About the author

Shawn Wernig is a web designer and developer, working primarily with Wordpress based websites. His company, Eggplant Studios is a small studio serving big clients in British Columbia, Canada.

One Reply to Changing the WordPress notification ‘From’ address

  1. Dev says:

    I think it can not be added in functions.php
    it’s a nice tutorial helped me. thank you

Leave a Reply