wp_mail_content_type
Allows you to change the content type of emails sent through wp_mail(). For example, from text/plain to text/html.
By default, the WordPress content type is 'text/plain'.
Usage
add_filter( 'wp_mail_content_type', 'wp_kama_mail_content_type_filter' );
/**
* Function for `wp_mail_content_type` filter-hook.
*
* @param string $content_type Default wp_mail() content type.
*
* @return string
*/
function wp_kama_mail_content_type_filter( $content_type ){
// filter...
return $content_type;
}
- $content_type(String)
The content type.
It can be:
- text/plain
- text/html
- multipart/mixed
- etc.
Examples
#1 Change the email content type
add_filter( 'wp_mail_content_type', 'get_content_type' );
function get_content_type() {
return 'text/plain';
}Changelog
| Since 2.3.0 | Introduced. |
Where the hook is called
wp_mail_content_type
wp_mail_content_type
wp-includes/pluggable.php 521
$content_type = apply_filters( 'wp_mail_content_type', $content_type );
wp-includes/formatting.php 6272
$content_type = apply_filters( 'wp_mail_content_type', $content_type );