How to change the "From" email in the confirmation emails?

We have confirmation emails turned on. When a user makes a donation, they get an email from "WordPress <wordpress@anchorgiving.com>". Is there any way to change that to the site owner's email address or at least change that it says "WordPress" as the name? Thanks.

  • Tyler Postle

    Hey Blake,

    Hope you're doing well today!

    You can add the following to your functions.php of your theme or as an mu-plugin:

    add_filter('wp_mail_from', 'new_mail_from');
    add_filter('wp_mail_from_name', 'new_mail_from_name');
    
    function new_mail_from() {
    	return 'yourname@yourdomain.com';
    }
    function new_mail_from_name() {
    	return 'Your Name';
    }

    source: http://sarathlal.com/change-default-sender-name-and-email-of-wordpress-notifications/

    Change the "yourname@yourdomain.com" and "your name" placeholders of course.

    If you're wanting to apply it to all your subsites then use the mu-plugin method. For that, just replace the placeholders then make it into a php file, name it anything you like, and upload it via:

    /wp-content/mu-plugins/

    I've attached a sample file so you can just unzip the folder then edit the placeholders and upload the file.

    Hope that helps! If you have any further questions just let us know.

    Cheers,
    Tyler

    PS. if you don't have an mu-plugin folder then you can just create one inside /wp-content/ it will work in both single sites and multisite installations.

  • Blake

    Thanks for this. The plugin looks like a viable solution, but all of our network sites have different owners, and they're all using the Fundraiser plugin. Hence, their outgoing emails from the plugin will need to say their site's main admin email address and the name of their site. We can't put one email address for all of our users. Is there a quick and dirty way to get those functions to call those options as variables that call on the site's admin settings, so that each site's outgoing emails from the plugin say their names? Thank you.

  • Panos

    Hi Blake ,

    Try a slightly modified version of Tyler's code:

    add_filter('wp_mail_from', 'new_mail_from');
    add_filter('wp_mail_from_name', 'new_mail_from_name');
    
    function new_mail_from() {
    	$blog_id = get_current_blog_id();
    	$blog_email = get_blog_option( $blog_id, 'admin_email' );
    	return $blog_email;
    }
    function new_mail_from_name() {
    	$blog_id = get_current_blog_id();
    	$blog_title = get_blog_option( $blog_id, 'blogname' );
    	return $blog_title;
    }

    Hope this helps!

    Kind regards,
    Panos

  • Blake

    Thank you very much. I installed this, and it definitely works, except that because it identifies the sender as the site's admin email, and that could be anything and is very likely to not be a domain email, the confirmation email that the sites now send out have the following message at the top in a warning yellow ribbon:

    This message may not have been sent by [whatever the site admin email is]. Learn more Report fishing

    Is there a way to prevent that message at all? If enough people report it as fishing - even though it's not - will that have negative consequences for our site?

    Thanks again for all your help!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.