WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Filter Reference/wp mail from name

Description

The wp_mail_from_name 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 <email@address.com>". The filter should return a string.

Parameters

$from_name
(string) (required) The "from" name
Default: None

Examples

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';
});

Notes

  • If you apply your filter using an anonymous function, you cannot remove it using remove_filter().

Change Log

Since: Version 2.3

Source File

wp_mail_from is located in wp-includes/pluggable.php

Related