Title: wp_staticize_emoji_for_email
Published: April 23, 2015
Last modified: February 24, 2026

---

# wp_staticize_emoji_for_email( array $mail ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_staticize_emoji_for_email/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_staticize_emoji_for_email/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_staticize_emoji_for_email/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_staticize_emoji_for_email/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_staticize_emoji_for_email/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_staticize_emoji_for_email/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_staticize_emoji_for_email/?output_format=md#wp--skip-link--target)

Converts emoji in emails into static images.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_staticize_emoji_for_email/?output_format=md#parameters)󠁿

 `$mail`arrayrequired

The email data array.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_staticize_emoji_for_email/?output_format=md#return)󠁿

 array The email data array, with emoji in the message staticized.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_staticize_emoji_for_email/?output_format=md#source)󠁿

    ```php
    function wp_staticize_emoji_for_email( $mail ) {
    	if ( ! isset( $mail['message'] ) ) {
    		return $mail;
    	}

    	/*
    	 * We can only transform the emoji into images if it's a `text/html` email.
    	 * To do that, here's a cut down version of the same process that happens
    	 * in wp_mail() - get the `Content-Type` from the headers, if there is one,
    	 * then pass it through the 'wp_mail_content_type' filter, in case
    	 * a plugin is handling changing the `Content-Type`.
    	 */
    	$headers = array();
    	if ( isset( $mail['headers'] ) ) {
    		if ( is_array( $mail['headers'] ) ) {
    			$headers = $mail['headers'];
    		} else {
    			$headers = explode( "\n", str_replace( "\r\n", "\n", $mail['headers'] ) );
    		}
    	}

    	foreach ( $headers as $header ) {
    		if ( ! str_contains( $header, ':' ) ) {
    			continue;
    		}

    		// Explode them out.
    		list( $name, $content ) = explode( ':', trim( $header ), 2 );

    		// Cleanup crew.
    		$name    = trim( $name );
    		$content = trim( $content );

    		if ( 'content-type' === strtolower( $name ) ) {
    			if ( str_contains( $content, ';' ) ) {
    				list( $type, $charset ) = explode( ';', $content );
    				$content_type           = trim( $type );
    			} else {
    				$content_type = trim( $content );
    			}
    			break;
    		}
    	}

    	// Set Content-Type if we don't have a content-type from the input headers.
    	if ( ! isset( $content_type ) ) {
    		$content_type = 'text/plain';
    	}

    	/** This filter is documented in wp-includes/pluggable.php */
    	$content_type = apply_filters( 'wp_mail_content_type', $content_type );

    	if ( 'text/html' === $content_type ) {
    		$mail['message'] = wp_staticize_emoji( $mail['message'] );
    	}

    	return $mail;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/formatting.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/formatting.php#L6132)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/formatting.php#L6132-L6189)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_staticize_emoji_for_email/?output_format=md#hooks)󠁿

 [apply_filters( ‘wp_mail_content_type’, string $content_type )](https://developer.wordpress.org/reference/hooks/wp_mail_content_type/)

Filters the [wp_mail()](https://developer.wordpress.org/reference/functions/wp_mail/)
content type.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_staticize_emoji_for_email/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_staticize_emoji()](https://developer.wordpress.org/reference/functions/wp_staticize_emoji/)`wp-includes/formatting.php` |

Converts emoji to a static img element.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_staticize_emoji_for_email/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.2.0](https://developer.wordpress.org/reference/since/4.2.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_staticize_emoji_for_email%2F)
before being able to contribute a note or feedback.