Skip to:
Content
Pages
Categories
Search
Top
Bottom

Change default email wordpress@mydomain.com

Viewing 9 replies - 1 through 9 (of 9 total)

  • Asynaptic
    Participant

    @synaptic

    found it! add this to functions.php

    add_filter(‘wp_mail_from’, ‘new_mail_from’);
    add_filter(‘wp_mail_from_name’, ‘new_mail_from_name’);

    function new_mail_from($old) {
    return ‘ENTER NEW EMAIL HERE’;
    }
    function new_mail_from_name($old) {
    return ‘ENTER NAME HERE’;
    }


    laurentdesserrey
    Participant

    @laurentdesserrey

    Hi @synaptic,

    I’ve the same issue. I tried to add this to functions.php but my site breakdown when I do that.

    Could you be more precise on where you put the code ? 🙂

    I’m not a (real) dev so not really comfortable yet with this.

    Thank you very much 🙂

    Laurent


    Henry
    Member

    @henrywright-1

    @synaptic I didn’t realise the auto emails were sent from ‘wordpress’@mydomain so thanks for this!


    @laurentdesserrey

    The code does go into your theme’s functions.php file. This is what I have:

    function custom_wp_mail_from( $email ) {
            $handle = 'laurentdesserrey';
    	$find = 'http://'; 
    	$replace = '';
    	$link = get_bloginfo( 'url' );
    	$domain = str_replace( $find, $replace, $link );
    	return $handle . '@' . $domain ;
    }
    add_filter( 'wp_mail_from', 'custom_wp_mail_from' );

    Note: change the handle. I’ve used ‘laurentdesserrey’ but you could use ‘admin’ or ‘support’ or ‘info’ – whichever works best for you.

    Reference: https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_mail_from_name


    laurentdesserrey
    Participant

    @laurentdesserrey

    Working great !

    Thanks 🙂


    Asynaptic
    Participant

    @synaptic

    @laurentdesserrey no idea why it would break, works fine for me and many other people – I found it on a blog with many comments saying it works great!

    Hentry’s code is a bit more complex and roundabout but it accomplishes the same thing. If you’re happy with it, great 🙂


    blastblast
    Participant

    @blastblast

    @laurentdesserrey

    @synaptic

    I am running a child theme of the bp-default…

    Should I add this code directly to my theme’s “functions.php”
    Or
    Should I create a file named “function.php” , add the email code there and then add it to my child theme’s folder?

    Also, at the bottom of the page here:
    https://codex.buddypress.org/themes/building-a-buddypress-child-theme/

    It states
    “(4) functions.php
    There is one exception to the template override rule — functions.php.
    If you create a blank functions.php file in your child theme, the parent theme (or in our case, the BuddyPress Default theme) functions.php will still be loaded.
    This will allow you to inherit existing functions from BuddyPress Default, but you can also add your own customized code in here as well!
    You must make sure you give your child theme functions a unique name, otherwise they will clash with the parent.”

    So, if I were to add the email code to my child theme – I should name it such as functions1.php?

    Thanks


    Tecca
    Participant

    @tecca

    Create a file called functions.php for your child theme. It’ll use the same name. What the quote above means is that the functions within that file should be named differently within the files (so you wouldn’t use the same two functions in both files, as it’ll cause problems).

    Since this code isn’t in your bp-default functions.php, you’re fine to paste it in your child theme’s functions.

    Or if you use Theme My Login, you don’t need to do this and can customize the emails.


    blastblast
    Participant

    @blastblast

    Okay thank you- so what I should do is create a blank functions.php, paste the email code in it, and simply upload that to my child’s theme?


    Tecca
    Participant

    @tecca

    Yep. Though be sure to add the php tags in the file. So:

    
    <?php
    function custom_wp_mail_from( $email ) {
            $handle = 'laurentdesserrey';
    	$find = 'http://'; 
    	$replace = '';
    	$link = get_bloginfo( 'url' );
    	$domain = str_replace( $find, $replace, $link );
    	return $handle . '@' . $domain ;
    }
    add_filter( 'wp_mail_from', 'custom_wp_mail_from' );
    ?>

    Paste that into a file and you’ll be good to go.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Change default email wordpress@mydomain.com’ is closed to new replies.
Skip to toolbar