The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Different line feed settings for HTML and plain text emails (3 posts)

  1. Simon Blackbourn
    Posted 2 years ago #

    My site sends out some plain text emails (e.g. password resets) and some HTML (e.g. Gravity Forms).

    This is causing a problem in that the Replace all line feeds ("\n") by <br/> in the message body? setting needs to be on for plain emails but off for HTML, otherwise the HTML emails have huge empty gaps in them.

    Is there a way I can achieve this using the mandrill_payload filter?

    Many thanks


  2. MC_Will
    Plugin Author

    Posted 2 years ago #


    We just released a new version of this plugin. We added a new filter, mandrill_nl2br, that allows you to change that flag on the fly.

    For example:

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

    Let me know how it goes.

  3. SupMA5TER
    Posted 2 years ago #


    I am having a similar problem. Your example above works if we have knowledge of tags of the outgoing message, but most of the time, we do not have such information beforehand. In such cases, all we have is if the message to be sent is text-only or has html part as well.

    For example WP notification emails are all text-based by default. I tried setting up a filter on 'mandrill_payload'. In the filter, I checked if $message['html'] is set to ascertain whether the email was text-only or not. Unfortunately, it appears that text-based or not, $message['html'] always contains the body of the message and $message['text'] is always empty. Please fix the plugin so that $message['html'] is empty for text-only emails and populated otherwise. So that we can do necessary operations within the mandrill_payload filter hook.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • wpMandrill
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.