Introduction
If you want to change the name and email address for outgoing WordPress messages/notifications, you just need to use a simple php code.
Why would you like to change these values?
As you already know, when a notification/message is sent to a WP user, it looks like it is sent from an email address looking like wordpress@yourwebsite.com and the sender name is WordPress.
This might not look very good and professional and the below code will give you the possibility to add your desired email address and sender name.
The PHP code to add custom sender name and email address
There are also WordPress plugins which can do this for you, but I prefer the coding solution.
All you have to do is to add the following php code to your functions.php
file in your theme folder (/wp-content/themes/yourthemefolder/):
// change email custom function
function zi_email_sender( $default_email ) {
return 'zi@zeninvader.com'; // change with your email address
}
// change sender name custom function
function zi_sender_name( $default_name ) {
return 'Zen Invader'; // change with your name
}
// add custom functions to wp filters
add_filter( 'wp_mail_from', 'zi_email_sender' );
add_filter( 'wp_mail_from_name', 'zi_sender_name' );
Conclusion
I really hope that you will find this solution really easy to be added to your WP website. To test this approach, just change the password for a certain user you have created (so you can check the email messages) and you will get a notification with the new email and sender name.
Comments closed
Please contact me, if you have any questions or suggestions.