By default, when an email is sent by WordPress to any registered user, the from email address is WordPress@yourwebsite.com and the name of sender is WordPress.
If you want to change the from email address and from name in any email sent by WordPress, then add the following code in the functions.php file of you active theme.
/*
Filter the name and email address from wp_mail
By www.agentwp.com
*/
function wpc_fromemail($email) {
$wpfrom = get_option( 'admin_email' );
return $wpfrom;
}
function wpc_fromname($email){
$wpfrom = get_option( 'blogname' );
return $wpfrom;
}
add_filter('wp_mail_from', 'wpc_fromemail');
add_filter('wp_mail_from_name', 'wpc_fromname');
Filter the name and email address from wp_mail
By www.agentwp.com
*/
function wpc_fromemail($email) {
$wpfrom = get_option( 'admin_email' );
return $wpfrom;
}
function wpc_fromname($email){
$wpfrom = get_option( 'blogname' );
return $wpfrom;
}
add_filter('wp_mail_from', 'wpc_fromemail');
add_filter('wp_mail_from_name', 'wpc_fromname');
The above code will change the default email to the email address of the WordPress admin, and name to the blog’s name.
You can also set custom values by editing the code above. But make sure that the email address you use is valid as people may reply to the same email address.