apply_filters( ‘wp_mail_from_name’, string $from_name )

Filters the name to associate with the “from” email address.

Parameters

$from_namestring
Name associated with the "from" email address.

More Information

  • The filter modifies the “from name” used in an email sent using the wp_mail() function. When used together with the ‘wp_mail_from‘ filter, it creates a from address like “Name <first.last@example.com>”. The filter should return a string.
  • If you apply your filter using an anonymous function, you cannot remove it using remove_filter() .

Source

$from_name = apply_filters( 'wp_mail_from_name', $from_name );

Changelog

VersionDescription
2.3.0Introduced.

User Contributed Notes

  1. Skip to note 3 content

    Example migrated from Codex:

    add_filter( 'wp_mail_from_name', 'custom_wp_mail_from_name' );
    function custom_wp_mail_from_name( $original_email_from ) {
    	return 'WordPress Email System';
    }

    It is not necessary to call another method if you can use anonymous functions (PHP 5.3.0+):

    add_filter( 'wp_mail_from_name', function( $name ) {
    	return 'WordPress Email System';
    } );
  2. Skip to note 4 content

    For subdomains why do we have to add:

    add_filter( 'wp_mail_from', function ( $email ) {
        return 'noreply@example.com';
    } );
    
    add_filter( 'wp_mail_from_name', function ( $name ) {
        return 'Sender Name';
    } );

    I didn’t know that international customers couldn’t send me messages for over a year T-T CF7 forms would just have a spinning mark. My German friend told me this. It’s for all subdomain sites not the main site. I’m glad I found this out now though.

You must log in before being able to contribute a note or feedback.