• Resolved chelminski

    (@chelminski)


    Hi ??
    Please add the option for the email to contain only plain text. Currently, I have appended to the beginning and end of every notification. This is problematic due to the automation of some processes.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    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

    Thread Starter chelminski

    (@chelminski)

    Thx. It works!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plain text in mail’ is closed to new replies.