By default, WordPress uses the from name "WordPress" and email "[email protected]" when sending notifications to users. It isn't convenient and you might want to change it into your blog name or something like that. This tutorial will show you how to do this just with simple code.
Open the functions.php
file of your theme and paste the following code into it:
add_filter( 'wp_mail_from', fn() => get_option( 'admin_email' ) );
add_filter( 'wp_mail_from_name', fn() => get_bloginfo( 'name' ) );
This snippet changes the default from name to your blog name and default from email to the admin email.
If you want to change it to something else, use this snippet:
add_filter( 'wp_mail_from', fn() => 'Your email' );
add_filter( 'wp_mail_from_name', fn() => 'Your name' );
Change the email address and from name to anything you want, then save file. From now, when sends notifications (for example, when new user registers), you can see the from address looks like: "Your Blog Name" <[email protected]>
.
Changing WordPress default email from name and address is simple, but useful. I wonder why WordPress doesn't use the default admin's information to do that. Hope in the future, WordPress will make it easy to adjust these information. But for now, you can use this small hack for this purpose.
If you're not familiar with coding, then you can use my plugin Falcon to do that. The plugin provides UI for you to change the default from name and email in its settings page. It also allows you to setup SMTP for emails.
Leave a Reply