WordPress sends us notifications – comment form submissions, plugin and theme updates, site updates, and more. Moreover, many plugins use the WordPress mailing subsystem so that you can receive all kinds of e-mails. And not just you as the administrator, but your users as well, and maybe even your subscribers. So it’s essential to know and, if necessary, customize the e-address and name WordPress uses for e-mails. Here’s a simple way to do it.
Default WordPress E-mail Name and Address
By default, WordPress uses the “wordpress” username and your domain name to send an e-mail. So if your site is “example.com“, the e-mail address that WordPress would use to send notifications is “[email protected]”. The sender’s name is “WordPress”.
Note that this default e-mail – [email protected] doesn’t exist! It’s just a placeholder for standard e-mails, and WordPress doesn’t assume that any of them will require a response. You can see why we would want to change it to something else.
We Want to Allow Users to Respond
Since the default “[email protected]” e-mail doesn’t exist, users won’t be able to reply to these messages. Usually, they don’t need to, and notification messages don’t require a response. But if you have a system that sends notices to regular users, for whatever reason, then you might want the ability for them to hit the “Reply” button so they can contact you.
Plus, even if no one wants to respond, it just looks better for an e-mail to come from an actual organization or person instead of from a generic application.
Code to Change the WordPress E-mail ID and Name
You can use many plugins to change WordPress’s e-mail for notifications. But I find the easiest way is to use this snippet of code in your functions.php:
function change_wordpress_email( $email ) {
return '[email protected]';
}
function change_wordpress_name( $name) {
return 'Bhagwad Park';
}
add_filter( 'wp_mail_from', 'change_wordpress_email' );
add_filter( 'wp_mail_from_name', 'change_wordpress_name' );
If you don’t know how to add this code, then refer to my tutorial on how to add code to WordPress using a custom plugin. It’s invaluable and will help you in the future to extend WordPress without tying yourself down to a given theme, and it’s also safer than messing with your theme’s functions.php.
This does two things:
- Replaces your e-mail address
- Returns the name WordPress uses in the “From” field
The above code uses my name and e-mail ID, so you should change it to whatever is appropriate for your website.
Ensuring that the E-mail Goes Through
A further challenge is ensuring that the e-mail WordPress sends with the new credentials reaches the recipient. There are two dangers:
- The receiving server will reject the mail entirely
- It will go to spam
Major e-mail providers like Gmail require you to create an SPF record on your DNS servers to specify which domain names are allowed to send e-mails on your behalf. So make sure you follow that tutorial. Another thing you should do is to ensure that the new e-mail ID uses the same domain name as the one on which your WordPress site resides.
If you want, you can replace the above “change_wordpress_email” function with the one below, which automatically extracts the domain name from the current WordPress “From” address and lets you input only the username:
function change_wordpress_email( $email ) {
$parts = explode( '@', $email );
return 'bhagwad@' . $parts[1];
}
In the above code, you don’t need to specify the domain name – just the first part of the e-mail ID.
There’s no good reason to retain the regular WordPress e-mail ID and name for the notifications your site sends. Instead, change it to something that not only looks professional but to which users can also respond if necessary.
I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!
Leave a Reply