Change Wordpress Default From Email Address Without Plugin

In Wordpress, there is this default Wordpress email, wordpress@domain.com 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,

wordpress default email from address Change Wordpress Default From Email Address Without Plugin

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;"><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;"><br /><%%KEEPWHITESPACE%%>		function _fromMail($email){<br /><%%KEEPWHITESPACE%%>			return "noreply@gowhereeat.com";<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;"><br />add_filter('wp_mail_from','_fromMail');<br />add_filter('wp_mail_from_name','_fromMailName');<br /><%%KEEPWHITESPACE%%>		function _fromMail($email){<br /><%%KEEPWHITESPACE%%>			return "noreply@gowhereeat.com";<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.

 

 

Like this post? Share it!

http://hungred.com/wp-content/plugins/sociofluid/images/digg_48.png http://hungred.com/wp-content/plugins/sociofluid/images/reddit_48.png http://hungred.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png http://hungred.com/wp-content/plugins/sociofluid/images/delicious_48.png http://hungred.com/wp-content/plugins/sociofluid/images/furl_48.png http://hungred.com/wp-content/plugins/sociofluid/images/technorati_48.png http://hungred.com/wp-content/plugins/sociofluid/images/google_48.png http://hungred.com/wp-content/plugins/sociofluid/images/myspace_48.png http://hungred.com/wp-content/plugins/sociofluid/images/facebook_48.png http://hungred.com/wp-content/plugins/sociofluid/images/twitter_48.png

Related posts:

  1. Tutorial: How to change plugin table structure in Wordpress this article explain the mistake of most Wordpress plugin developer...
  2. How To Exclude Page Permanently In Wordpress Without Using Any Plugin here is a way to permanently exclude pages globally across...
  3. Customize Wordpress Avatar Using Filter Hook Another Wordpress tutorial that uses Wordpress filter hook to customize...
  4. “You do not have sufficient permissions to access this page.” on plugin admin page after update to Wordpress 3.0 A small fix for wordpress plugin developer after an upgrade...
  5. Wordpress Text Formatting Problem – Solved! Due to Wordpress smart quote functionality, users who write code...

This entry was posted on Sunday, April 4th at 3:42 AM and is filed under How-to, Others. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are automatic closed after certain period. Please send the author an email instead.