Change the Sender Name and Address of WordPress Emails
Replaces the default "WordPress <wordpress@yourdomain>" sender with your site name and, optionally, an address of your choice.
Opens WPIDE on
Code
add_filter( 'wp_mail_from', function ( $email ) {
$custom = ''; // For example '[email protected]'. Leave empty to keep the current address.
return is_email( $custom ) ? $custom : $email;
} );
add_filter( 'wp_mail_from_name', function ( $name ) {
return 'WordPress' === $name ? wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) : $name;
} );
Notes
Use an address on your own domain so messages pass SPF and DKIM checks.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.