<?php
/* The wp_mail_from filter modifies the "from email address" used in an email sent using the wp_mail function.
* auto-detect the server so you only have to enter the front/from half of the email address, including the @ sign
* https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_mail_from
*/
function xyz_filter_wp_mail_from($email) {
/* start of code lifted from wordpress core, at /wp-includes/pluggable.php */
$sitename = strtolower($_SERVER['SERVER_NAME']);
if (substr($sitename, 0, 4) == 'www.') {
$sitename = substr($sitename, 4);
}
/* end of code lifted from wordpress core */
$myfront = "whateverIwant@";
$myback = $sitename;
$myfrom = $myfront . $myback;
return $myfrom;
}
add_filter("wp_mail_from", "xyz_filter_wp_mail_from");