Plain text in mail | WordPress.org

[ad_1]

Hi @chelminski

I hope you are doing well today.

We have a feature request in that matter but there is no ETA when this will be implemented. At the moment you can use this mu-plugin:

<?php

add_action( 'plugins_loaded', function() {
	add_filter( 'forminator_custom_form_mail_admin_message', function( $message, $custom_form, $data, $entry, $instance ) {
		$message = str_ireplace( array( '<br/>', '<br/>', '<br />'), ':fmnl:', nl2br( $message ) );
		$message = str_ireplace( '<li>','* ', $message );
		$message = str_ireplace( '</li>', ':fmnl:', $message );
		$message = str_ireplace( '</b>', ':', $message );
		add_filter( 'wp_mail_content_type', function( $content_type ) {
			return 'text/plain'; // Set the MIME Type as Plain Text (Important)
		});
		add_filter( 'wp_mail', function( $mail ) {
			if ( false === strpos( $mail['message'], ':fmnl' ) ) {
				return $mail; // Skip.
			}
			$mail['message'] = wp_strip_all_tags( $mail['message'], true );
			$mail['message'] = str_ireplace( ':fmnl:', "\n", $mail['message'] );
			return $mail;
		}, 10 );
		return $message;
	}, 10, 5 );
});

To learn more about how to install MU-Plugin to a site, please, check this out: https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

Kind Regards,
Kris

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer