If you own a WordPress-based website you most likely know what happens whenever one of your users (including you) loses his password: he clicks to the "forgot password?" link below the login screen, inserts the username or e-mail address and click the "obtain a new password" button.
Right after doing that, he will then receive a system-generated e-mail message containing a unique link that can be used to reset the password for his (or her) account.
If we take a look at this e-mail message, we can see that it shows your website name as a sender name and [email protected] as the sender e-mail address: those values are usually OK for most scenarios, but can be troublesome under certain circumstances - for example, if we are unable to directly send e-mail messages using that hostname domain as sender.
What if we want to change these default settings with custom values?
Luckily enough, there are at least two workarounds we can use to do that:
- manually modifying the function.php file, which requires a bit of PHP and WordPress coding knowledge;
- using a third-party plugin, which is arguably easier and faster to pull off.
In the following paragraphs we'll see how we can use these techniques to fullfill our task.
Modifying the function.php file
This method is slightly more complex, but it's way more customizable - especially if you're using a custom login page and/or you don't want to install a new plugin.
Here's how you can change the default sender name:
1 2 3 4 |
add_filter( 'wp_mail_from_name', 'custom_wpse_mail_from_name' ); function custom_wpse_mail_from_name( $original_email_from ) { return 'My Custom Sender Name'; } |
And here's how you can change the default e-mail address:
1 2 3 4 |
add_filter( 'wp_mail_from', 'custom_wpse_mail_from' ); function custom_wpse_mail_from( $original_email_address ) { } |
If you want to understand more about these filters, here are the corresponding references from the WordPress Codex:
- https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_mail_from_name
- https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_mail_from
Using a third-party plugin
If you don't want to mess out with the function.php file and just want to change these values in a quick and effective way, you can use one of the many free third party plugins available on the WordPress plugin directory, such as the useful CB Change Mail Sender Plugin created by Md Abul Bashar.
The plugin features a very simple to understand settings page which you can use to set up the new sender name and sender e-mail address values, just like shown in the following screenshot:
Conclusions
That's it: we hope that this guide will help those WordPress administrator that are looking for a quick and easy way to change the default sender name and e-mail address for their website.