Press "Enter" to skip to content

Best way to change WordPress email sender address and information without messing / intervening other plugin

Howard Lie 0

WordPress sends email with a default sender information such as “WordPress” as the sender name and “[email protected]” as email from address. This might be uncomfortable for some WordPress sites that wants to use their website’s name instead. Out there, on the internet, there are a lot of sites sharing the way to change your WordPress email sender address, but their method aren’t really good. Most of their solution to this problem is to download some plugin that change your WordPress site’s email sender info. But if you use that plugin and at the same time use other email-involved plugin such as Newsletter that sends email on its own, it will give you a big headache because it will overrides all outgoing mail from your WordPress site. Yes, every single mail are overrided!

 

The best way to change only email fromĀ “[email protected]” is to add some code in your functions.php file inside your theme’s folder.

1. Open your functions.php file inside your theme’s folder

2. Add this code :

// change email
add_filter('wp_mail_from', 'doEmailFilter');
add_filter('wp_mail_from_name', 'doEmailNameFilter');
function doEmailFilter($email_address){
if($email_address === "[email protected]")
return '[email protected]';
else
return $email_address;
}
function doEmailNameFilter($email_from){
if($email_from === "Wordpress")
return "Site's Name";
else
return $email_from;
}

3. Change “yourdomain.tld” into your domain

4. Change “no-reply” for WordPress default sender name

5. Change “Site’s Name” to your site’s name

6. You might need to change “WordPress” to the sender name of the email you received when your WordPress site sends an email to you. Usually, the name is “WordPress”. (Optional)

7. Save functions.php and you are done.

 

If you encounter any problems, please leave a comment below.

%d bloggers like this: