Contact Form 7 from adding paragraph and break tags to HTML emails

I'm trying to stop Contact From 7 from adding paragraph and break tags to HTML emails but can't figure it out. About 4 blank paragraph tags are added at the beginning of the email and two at the end.

This question brings up the same issue, and the fix is said to have come in a recent update but I have the most recent one and no luck.

Any ideas?

Topic plugin-contact-form-7 php Wordpress

Category Web


This seems to be a bug with the contact form plugin. You may look at the plugin source files to see if there are extra <p> tags.


Open the "classes.php" file in the CF7 plugin's "includes" folder and uncomment the following line (number 550) like so ...

//$body = wpautop( $body );

Hope this helps (you too)!

TIP: Minify your HTML-Email-Content with a HTML-Minifier - just to be safe ;)


I agree with David Garcia, in the textarea where you compile your form, any new line is converted to a
tag.

the paragraphs instead are automatically created by CF7 in rendering the forms. You've just to reset css to p tags inside the form.


I came to the conclusion that new lines (enter's) in the textarea are being converted to html line breaks (br's).

So if I put the input on the same line as the label, it shows correctly.

Hope it helps.


well if you updated and it didn't work, try doing the fix manually

as per this user

"The solution I came up with was a serious hack, but there was no other way around it short of editing the plugin's core code. Just stick this somewhere in your theme's functions.php and it should work:"

    add_filter("wpcf7_mail_tag_replaced", "suppress_wpcf7_filter");
function suppress_wpcf7_filter($value, $sub = ""){
    $out    =   !empty($sub) ? $sub : $value;
    $out    =   strip_tags($out);
    $out    =   wptexturize($out);
    return $out;
}

hope it helps - otherwise if you are really helpless u might have to roll back to an older version of contact form. Version 2.2.1 doesn't seem to have this problem while version 2.3 has it

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.