Change sender email address in WordPress

By default, your website sends emails from “[email protected].” To change this “Sender Email ID” or the “From Field” address on WordPress, you need to update the “wp_mail()” function, wp_mail_from (hook) & wp_mail_from_name (hook). However, you don’t need to be a guru to follow along with me.

In this post, I will show you how to change the default sender email address & name easily.

There are a couple of ways to do it. However, In this example, I will not use any plugin to do that. Instead, I will edit the functions.php in the theme.

How to change the sender’s email address in WordPress?

Default sender email address in WordPress
Default sender email address in WordPress

Login to your hosting or cPanel or FTP so you can navigate to the WordPress file system.

Open the “functions.php” file in your active theme.

Write the following functions at the bottom of the file (you can also copy-paste my code only by replacing it with your actual email).

// change sender's email address
function change_sender_email( $email_id ) {
  return '[email protected]';
}
add_filter( 'wp_mail_from', 'change_sender_email' );

Don’t forget to replace the example email address ([email protected]) with a real email.

Only with these lines of PHP, you can change the sender email address on your WordPress website.

However, this will only change the email address but not the sender’s name.

How to change the email sender’s name in WordPress?

The default name of the sender is “WordPress” and it looks like the following screenshot below.

Default sender's name in WordPress
The default name of the sender

To change the default name of the sender, open the functions.php file on your theme.

Write the following function at the very bottom.

// change sender's name
function change_sender_name( $sender_name ) {
  return 'John Doe';
}
add_filter( 'wp_mail_from_name', 'change_sender_name' );

And don’t forget to replace the example name (John Doe) with your real name.

That’s it. This is how you can change the sender’s name in WordPress.

Let’s combine these two things (email & name) together

I made two different sections for the default email address & name change. This is just to show you the process more precisely.

However, you need to change both the name & email address. So your final code will look like the following:

// change sender's email address
function change_sender_email( $email_id ) {
  return '[email protected]';
}
add_filter( 'wp_mail_from', 'change_sender_email' );

// change sender's name
function change_sender_name( $sender_name ) {
  return 'John Doe';
}
add_filter( 'wp_mail_from_name', 'change_sender_name' );

That’s it! This is how you can change both name & email of the sender. With this code in place, your email will look something to the following screenshot.

Email sender's name & email changed from default to custom
Final output

Reminding you again, don’t forget to replace the demo name & email address on the code.

Video instruction:

Conclusion

By default, your WordPress website sends emails from a nonexisting address which also does not look professional. Most email providers such as Gmail, Microsoft 360, Yahoo, Zoho, etc treat those emails as spam.

This is not the fault of WordPress CMS. Because they give you the option to send emails from your website. It’s your job is to customize the email address. And this is what I did in this post.

Finally, I want you to create/use a child theme to write the codes on your functions.php so it does not get overwritten by the next theme update. But if you’re not sure or don’t know about the child theme, I would suggest using a plugin to insert the code to your functions.php.