Change WordPress Default From Email Address Without Plugin

In WordPress, there is this default WordPress email, [email protected] where ALL WordPress installation will have. This default email is used on all your WordPress blog From address whenever you or your user receives an email from your WordPress blog. You will also notice that WordPress default email name is 'Wordpress' too instead of your own WordPress blog name. Something like the image shown below,

Well, having a default wordpress email address and name wasn't that bad but sometimes you would like to place it with your own branding name so that your users know its you instead of WordPress or something that is not associated with WordPress. If you search online, you will definitely find some ready made plugin available on the market but you might not want them due to various result such as efficiency, customization and etc. Furthermore, this is really easy to achieve and doesn't really required any plugin that might affect your WordPress blog performance.

WordPress Email Hook

The main thing we need to be aware of are the hooks needed to change the default WordPress From email addresses. If you dig into WordPress wp_mail function, you can easily notice there are two hooks that allow you to do this.

<pre class="brush: php; title: ; notranslate" title=""><br />add_filter('wp_mail_from','_fromMail');<br />add_filter('wp_mail_from_name','_fromMailName');<br />

The above are the two filter hooks that are required to change your default WordPress from email address.

 

WordPress Email Hook Functions

So we have our hooks, the next thing is to provide the function to change the name of the default email from address.

<pre class="brush: php; title: ; notranslate" title=""><br /><%%KEEPWHITESPACE%%>		function _fromMail($email){<br /><%%KEEPWHITESPACE%%>			return "[email protected]";<br /><%%KEEPWHITESPACE%%>		}<br /><%%KEEPWHITESPACE%%>		function _fromMailName($name){<br /><%%KEEPWHITESPACE%%>			return "Go Where Eat";<br /><%%KEEPWHITESPACE%%>		}<br />

It's pretty simple to understand from the above code, we are just passing in our name and email to overwrite the one given by WordPress.

 

Change WordPress Default From Email

For those who are not familiar with PHP coding and couldn't understand what the above means, all you need to do is to copy the below code to either a new plugin file or your function.php file in your theme folder and change the name and email address to the one you prefer.

<pre class="brush: php; title: ; notranslate" title=""><br />add_filter('wp_mail_from','_fromMail');<br />add_filter('wp_mail_from_name','_fromMailName');<br /><%%KEEPWHITESPACE%%>		function _fromMail($email){<br /><%%KEEPWHITESPACE%%>			return "[email protected]";<br /><%%KEEPWHITESPACE%%>		}<br /><%%KEEPWHITESPACE%%>		function _fromMailName($name){<br /><%%KEEPWHITESPACE%%>			return "Go Where Eat";<br /><%%KEEPWHITESPACE%%>		}<br />

For coders, this should be a piece of cake for you.