email sends from wordpress@domain.com even though I have it set to something else

My wordpress settings email is contact@domain.com. When I search my entire database for the email of wordpress@domain.com, it does not exist.

Yet my registration emails are still sent from wordpress@domain.com for some reason.

Read More

The only thing I can think of is that when I look in my wp_users table, I have no user with the ID of 1. I believe this is the default admin ID. I’m not sure who did it or when, but I think the default admin was deleted a long time ago and I just made my username admin. Perhaps if wordpress doesn’t find an admin email, it automatically goes to wordpress@?

I’m confused with this one.

Related posts

Leave a Reply

2 comments

  1. Ok, then you can try this
    You can set the header, just not with a parameter. WordPress uses “hooks” and the hooks you need are ‘wp_mail_from’ and ‘wp_mail_from_name’ hooks.

    Here are the hooks you might add to your theme’s functions.php file to modify the “From:” header when using wp_mail() to the email address Greg j :

    add_filter('wp_mail_from','yoursite_wp_mail_from');
    function yoursite_wp_mail_from($content_type) {
      return 'abc@example.com';
    }
    add_filter('wp_mail_from_name','yoursite_wp_mail_from_name');
    function yoursite_wp_mail_from_name($name) {
      return 'Greg j';
    }
    
  2. WordPress does not look at your admin email, it uses the made-up address, each time wp_mail() was called without a From header.

    // From email and name
    // If we don't have a name from the input headers
    if ( !isset( $from_name ) )
        $from_name = 'WordPress';
    
    /* If we don't have an email from the input headers default to wordpress@$sitename
     * Some hosts will block outgoing mail from this address if it doesn't exist but
     * there's no easy alternative. Defaulting to admin_email might appear to be another
     * option but some hosts may refuse to relay mail from an unknown domain. See
     * http://trac.wordpress.org/ticket/5007.
     */
    
    if ( !isset( $from_email ) ) {
        // Get the site domain and get rid of www.
        $sitename = strtolower( $_SERVER['SERVER_NAME'] );
        if ( substr( $sitename, 0, 4 ) == 'www.' ) {
            $sitename = substr( $sitename, 4 );
        }
    
        $from_email = 'wordpress@' . $sitename;
    }
    

    You can filter that from address and the name: changing notification emails from WordPress <wordpress>@mydomain.net to something else

    In some cases you must filter it: when your domain name is www.tld, WordPress will strip the www. and use an email address wordpress@tld.