• HI there,

    I saw a couple posts with users having this issue and tried the fixes but am not quite getting the desired results.

    My issue:

    When I check the option to “replace your line feeds by
    “, my password reset emails work perfectly, but Gravity Forms emails look terrible.

    I deactivated that option, and added the code recommended on this support thread: https://www.ads-software.com/support/topic/wpmandrill-affecting-password-reset-email-content-and-link-formatting?replies=17

    function forgotMyPasswordEmails($nl2br, $message) {
        if ( in_array( 'wp-retrieve_password', $message['tags']['automatic'] ) ) {
            $nl2br = true;
        }
        return $nl2br;
    }
    add_filter( 'mandrill_nl2br', 'forgotMyPasswordEmails' );

    The password reset emails still appear like this:

    Someone requested that the password be reset for the following account: https://csao.net/ Username: testuser If this was a mistake, just ignore this email and nothing will happen. To reset your password, visit the following address: /ourwebsite.com/wp-login.php?action=rp&key=2C4WNkhEGno3AVQhVqeX&login=testuser>

    So basically there are no line breaks and the URL isn’t clickable.

    I also tried the code on your FAQ page for the question: “My emails are broken and show weird CSS code” and the code in the following thread where the user was reporting the same issue with Gravity Forms emails (https://www.ads-software.com/support/topic/tags-being-injected-into-gravity-forms-email-notifications?replies=5).

    Can you please help me to sort this out? I’m using a child theme, so I’ve been adding the code to my functions.php file. I also tried the various function file edits with the “replace your line feeds by
    ” option checked and unchecked.

    Thanks for your urgent help!

    Juliana

    https://www.ads-software.com/plugins/wpmandrill/

Viewing 1 replies (of 1 total)
  • Here’s the code I’m using in my theme’s functions.php file to make wpMandrill and Gravity Forms play nicely together so that HTML and plain text emails both work with Mandrill:

    <?php
    
    // Add to functions.php and leave the “Content” box unticked in Settings > Mandrill
    // Be sure to omit the opening <?php tag when copying this code
    
    // Add paragraph breaks to plain text notifications sent by Mandrill
    add_filter('mandrill_payload', 'wpmandrill_auto_add_breaks');
    function wpmandrill_auto_add_breaks($message) {
    
    	$html = $message['html'];
    
    	$is_comment_notification = ( $message['tags']['automatic'][0] == 'wp_wp_notify_moderator' );
    	$is_password_reset = ( $message['tags']['automatic'][0] == 'wp_retrieve_password' );
    	$no_html_found = ( $html == strip_tags($html) ); 
    
    	// Add line breaks and links to messages that don't appear to be HTML
    	if ( $no_html_found || $is_comment_notification || $is_password_reset ) {
    		$html = wpautop($html);
    		$message['html'] = make_clickable($html);
    	}
    
    	return $message;
    
    }

    I’ll keep the gist here up to date if I change the code to work around any other issues I find: https://gist.github.com/nickcernis/8b87ac0a875e417b304b

Viewing 1 replies (of 1 total)
  • The topic ‘Issue with Gravity Forms Emails and Password Reset Emails’ is closed to new replies.