Support » Plugins and Hacks » Remove autop from Mail(2)

Remove autop from Mail(2)

  • Hi,

    I’m using Mail (2) to send a nicely formed html email to customers. How can I make autop stop messing up my emails?

    I tried this code:

    add_filter( 'wpcf7_mail_components', 'dontautop_wpcf7_mail_components', 10, 2 );
    function dontautop_wpcf7_mail_components($components, $contact_form) {
    	$mail_template = $contact_form->mail;
    	$regex = '/\[\s*([a-zA-Z_][0-9a-zA-Z:._-]*)\s*\]/';
    	$use_html = (bool) $mail_template['use_html'];
    	$callback = array( &$contact_form, 'mail_callback' );
    	$callback_html = array( &$contact_form, 'mail_callback_html' );
    	if ( $use_html )
    		$body = preg_replace_callback( $regex, $callback_html, $mail_template['body'] );
    		$body = preg_replace_callback( $regex, $callback, $mail_template['body'] );
    	$components['body'] = $body;
    	return $components;

    This code has two problems:

    1. It doesn’t recognize tags (like [your-name])
    2. It sends the email (not Email (2)) to both administrator and client.

    I would like to be able to turn off autop only for Email(2) keeping a way to recognize the tags. Is there any way I can do this?

    Thank you.


  • The topic ‘Remove autop from Mail(2)’ is closed to new replies.