WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Simon Blackbourn
    Member
    Posted 7 months 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

    http://wordpress.org/plugins/wpmandrill/

  2. MC_Will
    Member
    Plugin Author

    Posted 7 months ago #

    Hi,

    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
    Member
    Posted 5 months ago #

    Hi!

    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.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.