Using wpmandrill to send subscription notification from bbPress

The support forums for BulkWP runs on bbPress and I use wpMandrill to send all emails from BulkWP through the Mandrill App email service from MailChimp. Recently in bbPress v2.5.4 the logic to send topic subscription emails was changed in a major way which broke it for people who were using bbPress with wpMandrill. After spending almost a day debugging I finally got everything to work and thought of documenting it here so that it will be useful for others as well.

What changed in bbPress?

In bbPress till v2.5.4 whenever a new reply was posed to a topic, individual emails were sent to all people who have subscribed to that topic. The major downside to this approach is that if a topic has a lot of subscribers then it resulted in a major bottleneck and in most cases the script used to timeout or the mail server used to crash.

To fix this, in v2.5.4 all subscriber email addresses were moved to bcc and only a single email was triggered for all the subscribers. Also in the “to” a generic do not reply email address was used that was calculated using the domain name.

How this broke wpMandrill?

Unfortunately the above code change broke emails sent through wpMandrill in more than one ways.

Bugs in generating the “do not reply” email address

The following were the different bugs in the code that generated the “do not reply” email address.

  • The generated “do not reply” email address which was specified in the “to” filed was enclosed in angle bracket, which Mandrill API didn’t like.
  • If the domain name started with s, then it was stripped. eg: if the domain name is https://ssssean.com/, then the email address was noreply@ean.com
  • If the domain name has www, then the generated “do not reply” address also had ‘www’ in the email domain name. eg: noreply@www.example.com

All of these are documented in this post in bbPress support forum.

No BCC support in Mandrill API

Mandrill API doesn’t support more than one bcc email address and the wpMandrill plugin just used the first bcc address and silently ignored the others. Since the new change added all the subscribed email address to bcc, the email was sent only to the first email address and the rest were silently ignored.

How to fix these issues?

All the issues in generating the “do not reply” email address were fixed in this ticket. In addition to fixing the bugs, two more filters are introduced that allows you to change the default email address to something else if needed. The following are the filter names

  • bbp_get_do_not_reply_address
  • bbp_subscription_from_email
  • bbp_subscription_to_email

The changes are already merged into trunk and hopefully should be available as part of the next release. Till then you might have to manually edit the core file to change the default “do not reply” email address. The relevant code is in bbpress/includes/common/function.php file in the bbp_notify_subscribers function (around line number 1065)

Update: The above changes are now available from bbPress 2.5.6. If you are using bbPress 2.5.6 or above then you can change the “do not reply” address using the filters instead of manually editing the core files.

Regarding the issue with bcc support in Mandrill API, I found a way to trigger individual emails for a given list of email address after going over the Mandrill API documentation. Basically you have to sent the different email addresses as array in the “to” file with type set to “bcc” and then set the option preserve_recipients option to false. This will make Mandrill to trigger individual emails for each of the email address.

After I found about this, I looked into wpMandrill plugin source code to see if this can be done by hooking into the mandrill_payload filter. But unfortunately that was not possible. After some more debugging I finally found that it would be possible to this by hooking the wp_mail filter.

I quickly wrote a small plugin which hooks into wp_mail filter and converts all “bcc” address into the correct format that Mandrill expects. You can checkout the plugin in github. One word of caution. Even though this plugin works in my server, I have not fully tested all the corner cases. So do test this first in your dev server before installing it in a live site.

Limitations

The above plugin only works for the bbp_notify_subscribers function. But there is a similar function called bbp_notify_forum_subscribers which sends emails to all people who have subscribed to a forum when a new reply is posted.

Try it out and let me know if you face any issues and hopefully it will be useful for other people who also use bbPress with wpMandrill like me 🙂

49 comments

  1. Stephen White

    This is a handy plug in, Worked fine in test server but on live I do get an error – “trim() expects parameter 1 to be string, array given – ” everything executes and emails send. Just looking to make error page not show. Advice?

    • Sudar

      Can you post the entire error message?

    • dainel jones

      Delta Airlines JFK Terminal

      https://allairportsterminal.com/airlines/delta-airlines/delta-airlines-john-f-kennedy-international-airport-jfk-terminal/

      Delta Airlines JFK Terminal, providing a modern and efficient experience for travelers. The terminal offers a range of amenities, including spacious lounges, numerous dining and shopping options, and streamlined check-in and security processes. As one of Delta’s major hubs, the JFK terminal connects passengers to domestic and international destinations with seamless transfer services. Whether flying for business or leisure, passengers at Delta Airlines’ JFK terminal can expect a convenient and comfortable travel experience, enhanced by state-of-the-art facilities and customer-focused services.

  2. Jeremy Biron

    Thanks for sharing this plugin! Your plugin is working great to send my bbpress subscriptions with one exception.

    Unfortunately the WordPress system is still sending the regular emails to users as well when this function is triggered. So each time a reply email is sent, the user gets one from Mandrill and one from WordPress. Any ideas on what might be causing this?

    It’s probably something stupid I’m doing. Thanks again for putting this plugin together!

    • Sudar

      Hello Jeremy,

      That’s really strange. Is it happening for all emails that are sent through Mandrill in your WordPress installation or only for emails that are sent through bbPress?

      • Jeremy Biron

        Thanks for the reply Sudar. This issue is not happening with any other emails that WordPress is sending. It’s only with the bbpress emails.

        • Sudar

          Were you having this issue before you installed my plugin?

        • Sudar

          I was thinking about it a bit more and now I am thinking whether this might be because of some other plugins. Are you using any other plugins that do anything with email?

  3. Jeremy Biron

    Sorry for the delayed reply on this. Haven’t had time to look at it.

    Here are the only plugins I have enabled currently:
    bbpress
    bbPress – Subscription in Mandrill
    wpMandrill

  4. Jeremy Biron

    So I dug into this a little further. These emails are going to two different addresses.

    Email #1 via Mandrill – going to the correct email.
    Email #2 with no template/format – looks like it is going to noreply@www.blogdomain.com but is being received at the correct email address of the subscriber.

    • Sudar

      Is the second email going through Mandrill as well or is it going through WordPress? I mean if you check your Mandrill logs is the second email appearing there?

    • Sudar

      Also does the domain of your blog includes www or not?

      • Doug Smith

        I can confirm the behavior with receiving multiple e-mails. It only started after I installed your plugin.

        The first e-mail is going through WordPress and my server. It has none of the Mandrill headers in it and does not show up in my Mandrill logs.

        The second e-mail goes through Mandrill. It has the Mandrill headers and the formatting and newlines are stripped out of it.

        My domain does not include a www. I had the problem with the letter “s” being stripped out so I just hardcoded the noreply@domain.com address in bbPress’ includes/common/functions.php in lines 1065 and 1205.

      • Jeremy Biron

        I am still stuck on this. It is killing me.

        The first email goes through Mandrill and the second does not. The second sends through WP and has a “noreply” email address. We use www with the domain/installation.

  5. Jeremy Biron

    I think I have found the issue. The system is trying to send to the noreply address that is used for outgoing emails. See the below API response. It sent to 3 addresses. 2 subscribers and the reply address.

    I think the failed noreply address is causing the system to throw and exception and use wp_mail after it has already sent via Mandrill.

    How do I stop it from sending to noreply@www.my-domain.com?

    [
    {
    “email”: “”,
    “status”: “invalid”,
    “_id”: “e3d513c3dfe142bb892a5392ef563d7a”,
    “reject_reason”: null
    },
    {
    “email”: “subscriber-email-2@gmail.com”,
    “status”: “sent”,
    “_id”: “243535bbf22f4fcf9d2ea0a90e30f7a5”,
    “reject_reason”: null
    },
    {
    “email”: “subscriber-email@gmail.com”,
    “status”: “sent”,
    “_id”: “f7ae7f5eb3fb43c9adfb2208a61a1d89”,
    “reject_reason”: null
    }
    ]

    • Doug Smith

      I can confirm this on my server as well. The log is showing every message being sent to the noreply address.

    • nixon Lesteraction

      I believe I’ve identified the problem. The system is attempting to send to the outgoing email’s noreply address. Check out the API answer below.

  6. Chris

    The multiple email issue happens for me too.
    I have been able to get around it by using another plugin – that stops all wp_mail() – but still allows Mandrill emails to get through.
    Plugin: “Stop Emails” (https://wordpress.org/plugins/stop-emails/)
    With that plugin activated, the bbPress notification emails still go out through Mandrill

  7. st

    Is the plug-in still needed after I have updated to bbPress 2.5.6?

    • Sudar

      No. It is not.

      Let me know if you still face any issues with it.

      • Chris

        Interesting, however, it seems that we DO still need the plugin – even after updating to 2.5.7
        Maybe we’re “doing something wrong” — but we’re very thankful to have your plugin!
        We’re still using it – and it is working.

  8. Vanessa

    Hey Sudar,

    Thanks for all your work on this.
    I’ve been unable to figure this out – on bbPress 2.5.9, WordPress 4.5.2
    I tried using your plugin, but that doesn’t seem to route mails through Mandrill, it still seems to send them from WordPress. I don’t get duplicate emails, just the one.

    Buddypress emails have no problem, just bbPress.

    I’d love any ideas you had to fix this – been driving me a little nuts 🙂

  9. read more here

    Wood home furniture possesses one thing really organic concerning it.
    There is this sense of warmth, of nature as well as of sophistication that can be actually be located in wood home furniture.
    Wood is born from the planet.

  10. Qunton Decock

    Get the latest detailed road maps to ensure fast and accurate navigation. Express makes software updates easy to install. Download the latest maps to a memory card for easy transfer to your marine device. Garmin express

  11. Zach Tyson

    Can you share more about this.

  12. Navas Bruce

    Plugin for WordPress websites that allows users to send transactional emails through the Mandrill email service provided by Mailchimp. It enables more reliable email delivery for important messages such as password resets, order confirmations, and notifications.

  13. gkuyu yuuyf

    Download and Use this Hd Streamz App. It is not difficult to use just download from here according to the provided downloading steps and use.

  14. watchwrestling

    WatchWrestling is an online platform that aggregates wrestling content from various promotions, allowing fans to watch their favorite matches, shows, and events conveniently from their devices. Whether you’re into WWE, AEW, NJPW, or any other wrestling federation, WatchWrestling aims to provide a comprehensive viewing experience.

  15. watchwrestling

    If you’re a wrestling fan, you know how important it is to stay up-to-date with all the latest matches, storylines, and live events. The thrill of watching your favorite wrestlers perform their high-flying moves and dramatic takedowns is unmatched. But finding a reliable source to watch wrestling online can sometimes be a challenge. Enter WatchWrestling, your ultimate solution for streaming wrestling content from around the globe.

  16. laimstone stone

    wqFseFVs

  17. laimstone stone

    The story of Suhagan teaches valuable lessons about the importance of family, the strength of character, and the power of hope.

  18. Alikhanbaba Baba

    The story of WatchWrestling teaches us about the power of fan-driven platforms and the lengths to which passionate communities will go to stay connected with the content they love.

  19. Justin Bieber

    From popular mainstream titles to obscure and niche genres, 9anime provides fans with the ability to stream or download anime content in high quality, often with multiple language options for subtitles.

  20. zorotv

    Thank you for providing such valuable content! Your website is well-organized and offers great insights on. I appreciate the time and effort you’ve put into making the information both engaging and easy to understand. Looking forward to exploring more of your content in the future!
    https://zorotv.com.in/

  21. zorotv

    Thank you for providing such valuable content! Your website is well-organized and offers great insights on.
    https://zorotv.com.in/

  22. watchwrestling

    In today’s digital landscape, watching wrestling online has never been easier or more accessible. Whether you’re a WWE loyalist or an indie wrestling aficionado, there’s a streaming service tailored to your needs. So grab your favorite snacks, pick a platform, and get ready to dive into the electrifying world of professional wrestling, all from the comfort of your own home.

  23. 9animestv

    Thank you for providing such valuable content! Your website is well-organized and offers great insights on. I appreciate the time and effort you’ve put into making the information both engaging and easy to understand.
    https://9animes.link

  24. 9anime

    Watch Official 9anime online all anime in High Quality videos 1080P and 720P with SUB and DUB.

  25. ClickSud

    Using wpMandrill to send subscription notifications from bbPress is a smart choice! It enhances email deliverability and ensures your users receive timely updates. By integrating wpMandrill, you can streamline communication and improve user engagement within your community. It’s a great way to keep subscribers informed and connected! clicksud

  26. clicksudbiz

    Integrating wpMandrill for sending subscription notifications from bbPress is a fantastic idea! It streamlines communication with users and ensures that important updates are delivered reliably. This can significantly enhance user engagement and keep the community informed. I’d love to hear more about the setup process and any tips for optimizing email deliverability! <ahref=”https://clicksudbiz.net/”>clicksudbiz.net

  27. clicksudbiz

    Integrating wpMandrill for sending subscription notifications from bbPress is a fantastic idea! It streamlines communication with users and ensures that important updates are delivered reliably. This can significantly enhance user engagement and keep the community informed. I’d love to hear more about the setup process and any tips for optimizing email deliverability!
    clicksudbiz.net

  28. basahjeruk

    Integrating WP Mandrill with bbPress to send subscription notifications is a smart way to enhance user engagement on your forum. By leveraging Mandrill’s reliable email infrastructure, you ensure that your notifications are both fast and efficient, improving the user experience for those following threads. This setup also provides better email deliverability and tracking capabilities, which are often critical in maintaining active, engaged communities. For any bbPress-powered forum, this integration adds a professional touch by keeping users informed in real-time, helping to foster continued discussion and participation. basahjeruktv3

  29. Clicksud

    Using WP Mandrill to send subscription notifications from bbPress is an effective way to improve communication and engagement within your forum. By integrating Mandrill’s robust email delivery system, you can ensure timely and reliable notifications, keeping users up-to-date with new posts and discussions. This not only enhances the overall user experience but also helps in maintaining active participation by ensuring that important updates don’t get lost in spam or delayed. For forums looking to streamline their notification system, this integration offers a powerful and professional solution. Clicksud

  30. Muhammad Khuram

    Thanks for sharing this plugin! Your plugin is working great to send my bbpress subscriptions https://myasiantv.onl

Leave a Reply

Your email address will not be published.

*