WordPress.org

Ready to get started?Download WordPress

Forums

wpMandrill
plaintext emails converted to HTML remove newlines (5 posts)

  1. yoav.aner
    Member
    Posted 1 year ago #

    Hey Mandrill,

    I'm just trying out your wordpress plugin. It looks very nice, but it seems to convert plaintext emails to HTML, which causes line breaks to be removed...

    We are using eshop, and it generates order confirmation emails as plaintext. When we send them via standard SMTP it looks fine, but via wpMandrill, I can see that it converts the message to HTML (+plaintext), and all the newlines are missing...

    Also - as a loosely related suggestion. It would be nice to be able to install the plugin but *not* override wp_mail. This way I can decide to call wpMandrill::mail from my functions.php for some emails, but all other email sent via wp_mail will go as before...

    Cheers
    Yoav

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

  2. Ovidiu
    Member
    Posted 1 year ago #

    same problems here: losing the newlines inside the mails generated by WordFence

  3. MC_Will
    Member
    Plugin Author

    Posted 11 months ago #

    Did you try the 'Content' checkbox in wpMandrill settings? I think it solves that issue.

    And thanks for the suggestion! It will be added to v1.28. You'll have to use the wpMandrill filter (mandrill_payload) though. By adding a new parameter (force_native) to true, it will fall back to the native wp_mail() function.

    Stay tuned!

  4. yoav.aner
    Member
    Posted 11 months ago #

    Thanks Will,

    I didn't notice the 'Content' checkbox. The problem however is that I do send both text and HTML email, so it might solve the plain-text email problem, but then introduce problem with my HTML emails...

    Being able to control whether an email goes via mandrill or wp_mail would be very nice. I'm not sure I fully understand the proposed change via the filter, but as long as there's a way to do it, I'd be happy. Currently I monkey-patch your plugin to do so, pun intended ;-)

    Cheers
    Yoav

  5. joshf
    Member
    Posted 7 months ago #

    Often the sites I work with send out a combination of plaintext and HTML emails, depending on the plugins installed or any added functionality.

    When I use wpMandrill's 'Content' option, linebreaks are added to both plaintext and HTML emails. This works great for plaintext emails but not for HTML (it adds an extra <br> after every line break, including closing tags).

    Here's a quick function I added to functions.php that seems to have well so far on a variety of sites. Basically, just add a filter to mandrill_payload that applies wpautop to the content instead of using the 'Content' option in wpMandrill.

    function op_mandrill_payload($message) {
        // Add wpautop to message content
        $message['template']['content'][0]['content'] = wpautop($message['template']['content'][0]['content']);
        return $message;
    }
    add_filter('mandrill_payload', 'op_mandrill_payload');

    This adds line breaks when needed, but not after closing tags. The result is an nearly all-inclusive solution for both plaintext and HTML emails.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic