apply_filters( 'wp_mail_content_type', string $content_type )

Filters the wp_mail() content type.

Parameters Parameters


(string) Default wp_mail() content type.

Top ↑

Source Source

File: wp-includes/pluggable.php

View on Trac

Top ↑

Changelog Changelog

Version Description
2.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Helen Hou-Sandi

    Switch to HTML formatted email when using wp_mail():

     * Filter the mail content type.
    function wpdocs_set_html_mail_content_type() {
    	return 'text/html';
    add_filter( 'wp_mail_content_type', 'wpdocs_set_html_mail_content_type' );
    $to      = '';
    $subject = 'The subject';
    $body    = 'The email body content';
    wp_mail( $to, $subject, $body );
    // Reset content-type to avoid conflicts --
    remove_filter( 'wp_mail_content_type', 'wpdocs_set_html_mail_content_type' );

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