Using a multi-site trying to change the "from" email without success

Hello, strange issue I am attempting to figure out regarding the setting the "from" email address in the headers.

I am runing a wordpress multisite. I am processing a form and seding a confirmation email after the form is processed

I am attempting to manually set the headers to have the "from" email come from:

get_option( 'admin_email' )

I am also manually setting the reply-to email be:

get_option( 'admin_email' )

SO they should be the same.

However when the email is sent, the reply-to email is as expected from the non-main domain blog, however the from email is coming from the main site admin email.

Scratching my head on this, anybody have any ideas? This a non-related wpmudev question, and strictly a wordpress question, but would love to know if any experts out there might have some incite.


  • Ben

    @Jack Kitterhing

    Thanks for the response, here is the function I am using in my template:

    function stripe_email_before_send(&$to, &$subject, &$body, &$headers) {
           $subject = get_option( 'blogname' ) . ' - SUPERSTAR '.$subject;
           $headers = "From: Support SUPERSTAR <" . get_option( 'admin_email' ) . ">\r\n";
           $headers .= "Reply-To: SUPERSTAR <" . get_option( 'admin_email' ) . ">\r\n";
           return true;

    I added the words SUPERSTAR in my testing to make sure this piece of code was being used.

    The email sends, the subject is coming from here, the reply-top is coming from here, but the from is different.

    I tried working with the developer of the plugin and he is scratching his head on it, but he also has never worked with a multi-site I think it has something to do with that.

    Any ideas would be great!

  • Ben

    @Jack Kitterhing

    After going through the codex I figured out the problem.

    When modifying the headers that are sent to the wp_mail function, changing the "from" will have no effect in the multi-site environment. To modify the from email you must use the following filters:

    add_filter( 'wp_mail_from', function($email){
                    return get_option('admin_email'); // Or set this to any email you like
                add_filter( 'wp_mail_from_name', function($name){
                    return ''; //two single quotes here to make it blank
                                // or set this to any 'your name' you like

    Hope that helps any people scratching their head like I was.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.