apply_filters( 'wp_mail_content_type', string $content_type )

Filters the wp_mail() content type.


Description Description


Parameters Parameters

$content_type

(string) Default wp_mail() content type.


Top ↑

Source Source

File: wp-includes/pluggable.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
2.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 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      = 'sendto@example.com';
    $subject = 'The subject';
    $body    = 'The email body content';
    
    wp_mail( $to, $subject, $body );
    
    // Reset content-type to avoid conflicts -- https://core.trac.wordpress.org/ticket/23578
    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.