Bulk email without duplicates

Imagine a member has selected groups and sub-categories he is interested in.

I want to send an announcement to those who selected either of those groups and sub-categories.

Example: In a city made of the global main city, several boroughs and matters.
I would also have groups that are borough-matter specific.

The user can select:

  • A specific matter (Which as a general group),
  • A group in his borough for this matter,
  • A group in two other borough for this matter,
  • A second specific matter (Which as a general group),
  • All groups in all boroughs for this matter,
  • The main group for the main city;

If I wish to send an email to one or more groups or subcategories in these groups, some users might end up receiving more than one email of the same announcement, especially if the person selected the main city group that would forward the info from all boroughs and matters, plus some subgroups, etc.

The question: How can I prepare a mailing touching more than one targeted group and sub-categories list, duplicate-free, and send that message?

  1. Do I need to use an external script?

  2. Do I need an external email processor?

Thanks

Marc

If you require guaranteed duplicate-free delivery across arbitrary sets of groups and categories, you must:

  • Export user lists from the targeted groups or categories.
  • Merge and deduplicate these lists, either manually or using a script.
  • Use an external email processor to send the message to the deduplicated list.

This is the most robust way to ensure that users don’t receive the same announcement multiple times.

Thanks, Do you know if we can automate that, such as requesting the API to receive messages for each new member registration/withdraw or group/category selection, and receive only the new changes OR (less good) the whole list with their group/category, that can be requested by a Python program?

(I can manage to code Python). The question is more about automating communication between Discourse and Python AND Python and Mailing processor.

Discourse provides a robust REST API that allows you to:

  • List all users, groups, and user-group memberships
  • Monitor new user registrations and group join/leave actions (via polling or webhooks)
  • Retrieve category membership configurations

You can query either the full list or attempt to track recent changes. For full incremental change detection, you may need to implement time-based checks and manage differences locally. Authentication is handled through HTTP headers (Api-Key, Api-Username).

However, for more efficient and integrated control, I recommend creating a custom Discourse plugin. A plugin runs inside the Discourse server environment and provides direct access to Discourse internals, such as:

  • User, group, and category membership updates
  • Lifecycle event hooks for registrations and group changes
  • Direct access to Discourse’s internal APIs and database

This approach gives you real-time capabilities and greater flexibility for implementing automated workflows like mail handling or user segmentation.

  1. Can we create a plugin that will work on our instance even if it is hosted by Discourse, or we need to host it?

  2. Then, for emailing, do I need to export the list created by the plugin?

  3. What would a plugin do? Can I create a kind of long list from within the Discourse server? Or the idea is to send info to another server?

Thanks

If it’s an unofficial plugin, I think you can only install it on the Enterprise plan, otherwise you’ll have to self-host it.

  • Generate dynamic lists (user/group/category data) and display or store them within Discourse.
  • Export data to a file, or create downloadable admin reports.
  • Make HTTP(S) requests to another server (e.g., push user list updates to your Python/email tool).
  • Trigger webhooks, schedule tasks, or integrate directly with external APIs—all from inside Discourse, with no polling required.