How to change a WordPress site’s default email sender details without changing the administrator email
Background
In WordPress, the administrator’s email address is used as the default “from” address when sending system emails, such as password resets, new user registrations, comment notifications, and others.
When WordPress sends an email, it uses the following criteria to determine the “from” address and “from” name:
- From Address: The administrator email address. This email address is set in your WordPress settings (Settings > General > Email Address).
- From Name: The name of your website. This name is set in your WordPress settings (Settings > General > Site Title).
Solution
To change the default email sender details in WordPress without changing the administrator email, you can use code snippets or plugins. Here’s how to do it using both methods:
Method 1: Using a plugin
Have a WordPress email problem right now? Ask us about it.
We’ll attempt to publish a solution ASAP for free. Challenge us!
If you prefer using a plugin instead of modifying code, there are several plugins available that can help you modify the default email sender details. One such plugin is WP Change Email Sender.
Here’s how to use it to change the email sender details:
- Install and activate the “WP Change Email Sender” plugin from your WordPress dashboard.
- After activation, navigate to Settings > General and scroll down to WP Change Default Mail Sender.
- In the “From Email” field, enter the email address you want to use as the default sender.
- In the “From Name” field, enter the name you want to appear as the default sender.
- Save your settings by clicking the “Save Changes” button at the bottom of the page.
Now, the default sender email address and name will be changed to the ones you’ve set in the plugin settings, without affecting the administrator email.
Method 2: Using a code snippet
You can use the wp_mail_from
and wp_mail_from_name
filters to change the sender’s email address and name.
Add the following code to your theme’s functions.php
file or a custom plugin file:
function custom_wp_mail_from( $original_email_address ) {
return '[email protected]'; // Replace with your desired email address
}
add_filter( 'wp_mail_from', 'custom_wp_mail_from' );
function custom_wp_mail_from_name( $original_email_from ) {
return 'Your Name'; // Replace with your desired sender's name
}
add_filter( 'wp_mail_from_name', 'custom_wp_mail_from_name' );
Remember to replace the placeholders with the actual sender details you want to use.