There’s the wpcf7_autop_or_not function that relies on WPCF7_AUTOP constant you can define in your functions.php however it doesnt fix for me
@frafor: Correct, there is wpcf7_autop_or_not filter and the WPCF7_AUTOP constant, but they seem to be only applied to the form output and not to the email.
THIS IS VERY IMPORTANT
$html = $header . wpcf7_autop( $body ) . $footer;
It has broken all my html mails (in many websites)
Just in case someone wonders, Contact Form 7 5.7.1 still adds unwanted spaces into my HTML email (I am having a table within the email) and I could not find a filter to prevent that from happening. Still have to keep using 5.6.4 for right now…
Provisional solution for the HTML mail:
in line 93 the /wp-content/plugins/contact-form-7/includes/mail.php
$html = $header.wpcf7_autop($body).$footer;
CHANGE TO
$html = $header.$body.$footer;
In case someone wonders, the issue still persists in Contact Form 5.7.2.
Unfortunately, also in version 5.7.3 p tags are automatically added to the email in places where they should not be. E.g. they are added to <td> elements inside a table:
<table>
<tbody>
<tr><th>Name:</th><td>[your-name]</td></tr>
<tr><th>Company:</th><td>[your-company]</td></tr>
<tr><th>Email:</th><td>[your-email]</td></tr>
<tr><th>Phone:</th><td>[your-phone]</td></tr>
<tr><th valign="top" style="vertical-align:top">Message </th><td>[your-message]</td></tr>
</tbody>
</table>
Please allow us to turn off/bypass the wpcf7_autop in the email. Or prevent <p> tags from being inserted into a table.
Let me know if you have any questions. Thank you in advance for considering making these changes.