apply_filters( 'wp_mail_from', string $from_email )

Filters the email address to send from.


Parameters Parameters

$from_email

(string) Email address to send from.


Top ↑

Source Source

File: wp-includes/pluggable.php

View on Trac



Top ↑

Changelog Changelog

Changelog
Version Description
2.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 2 content
    Contributed by Elio Rivero

    Example of how to use this filter to update the user portion of the email address to send from.

    <?php
    /**
     * Filter the email address to send from and replace the user.
     *
     * @param string $from_email Email address to send from.
     *
     * @return string The new email address.
     */
    function wporg_replace_user_mail_from( $from_email ) {
    	// This will give us and array with the email user and the domain
    	// like this [ 'wordpress', 'example.tld' ]
    	$parts = explode( '@', $from_email );
    
    	// Add our new email user, add @ again, and append the domain
    	// This will be hello@example.tld
    	return 'hello@' . $parts[1];
    }
    
    add_filter( 'wp_mail_from', 'wporg_replace_user_mail_from' );
    

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