Ready to get started?Download WordPress


[resolved] Line break tags being injected into Gravity Forms email notifications (4 posts)

  1. cruelmelody
    Posted 3 months ago #


    I'm using Gravity Forms with wpMandrill, and when email notifications are received by the system, rogue tags keep getting injected above the email content creating a large grey block. I was wondering if anyone else had encountered this problem?

    History of the issue:
    After getting in touch with the Gravity Forms, they've advised me that there's no way to fix this with a CSS override, and that another third party plugin may be causing the issue.

    After doing some detective work, it's definitely wpMandrill causing the problem. When the plugin is disabled and email notifications are tested, the email is formatted correctly and isn't stuffed full of line breaks. When I turn it back on again and retest, the large grey block appears again caused by the line breaks.

    If anyone could suggest a fix, that'd be a great help. I'll raise an internal ticket if need be. Thanks!

  2. chrishajer
    Posted 3 months ago #

    Did you see this in the FAQ:


    My emails are broken and show weird CSS code

    In version 1.09, we added a setting that allows you to tell the plugin if you want to replace your line feeds by
    . Try playing with that switch.

    If it works for certain emails but doesn't work for others, you might want to modify this setting using the mandrill_nl2br filter. For example, if you don't want to use this filter for the "forgot password" emails, add something like this to your theme's functions.php file:

    The tag wp_GFCommon::send_email should make this filter apply only to Gravity Forms emails sent by Mandrill:

    add_filter('mandrill_nl2br', 'skip_nl2br_for_gf');
    function skip_nl2br_for_gf($nl2br, $message) {
    	if (in_array('wp_GFCommon::send_email', $message['tags']['automatic'])) {
    		$nl2br = false;
    	return $nl2br;
  3. bodoggy
    Posted 3 months ago #

    Hi Chris, I'm working with cruelmelody on this issue.

    I was able to fix the issue by un-ticking this option in wpMandrill settings:

    Replace all line feeds ("\n") by <br/> in the message body?

    The downside is that plain-text emails don't have proper line breaks anymore, but we'll be able to solve that by applying the filters selectively.

    I'll ask cruelmelody to mark this as "resolved".

    Thanks for your assistance!

  4. cruelmelody
    Posted 3 months ago #

    Thanks for your help, Chris. Much appreciated.


You must log in to post.

About this Plugin

About this Topic