How to Change the “From” Name in WordPress Emails

Home » Snippets » How to Change the “From” Name in WordPress Emails
0

Created with:

Visibility: 

public

Creator: WPTurbo Team

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project

Have you ever wanted to change the "From" name that appears when sending emails from your WordPress website? By default, WordPress uses the site name or the admin email name as the sender’s name. However, there may be instances where you want to personalize the sender’s name or use a different name altogether. In this article, we will guide you through the process of changing the "From" name in WordPress emails, allowing you to customize the sender’s name to better align with your brand or website. Let’s dive in!

					function wpturbo_change_wp_mail_from_name( $from_name ) {
    return 'Your New From Name';
}
add_filter( 'wp_mail_from_name', 'wpturbo_change_wp_mail_from_name' );
				

The code snippet above demonstrates how to change the "From" name in email messages sent through WordPress. By default, WordPress sends emails with the "From" name set to the site’s title.

To accomplish this customization, we create a new function called wpturbo_change_wp_mail_from_name. This function takes in the existing "From" name as a parameter, which is represented by the variable $from_name. Inside the function, we simply return the desired new "From" name as a string. In this example, we have set it to ‘Your New From Name’.

To apply this change, we use the add_filter function, which allows us to modify the value of the wp_mail_from_name filter hook. We pass two arguments to this function: the name of the filter hook we want to modify (wp_mail_from_name) and the name of the function that will be used to modify it (wpturbo_change_wp_mail_from_name).

By including this code in your theme’s functions.php file or a custom plugin file, you can easily change the "From" name for all outgoing emails sent by WordPress.

This customization can be particularly useful when you want to display a more personalized or branded "From" name in your email communications with users. For example, if your website is called "My Awesome Blog," you can use this code snippet to change the "From" name in emails to show "My Awesome Blog" instead of your site’s title.

Register an account to save your snippets or go Pro to get more features.