Change @WordPress from email address and from name sent out from website

WordPress sends a few emails out from a website including password reset emails that have a from email address [email protected] they also have a from name of WordPress.

Two WordPress filters can change these values wp_mail_from and wp_mail_from_name – add the below code in your child themes functions.php and change the appropriate values.

add_filter('wp_mail_from', 'prefix_email_from');
// Change default WordPress from  email address
function prefix_email_from( $new_email ) {
 return '[email protected]'; // Change email address
}

add_filter('wp_mail_from_name', 'prefix_name_from');
// Change default WordPress from name
function prefix_name_from( $new_name ) {
	return 'Company Name'; // Change from name
}

You could also bring in option values already created in the Settings > General page and use the Blogname and Admin Email values…

add_filter('wp_mail_from', 'prefix_email_from');
// Change default WordPress from  email address
function prefix_email_from( $new_email ) {
	$admin_email = get_option( 'admin_email' );
 return $admin_email;
}

add_filter('wp_mail_from_name', 'prefix_name_from');
// Change default WordPress from name
function prefix_name_from( $new_name ) {
	$blogname = get_option( 'blogname' );
	return $blogname;
}

Leave all Comment