Update Digest Email Using Plugin

Hi everyone,

I’m looking to enhance our digest email by adding a new section—a box that displays a short list of jobs (each with a title and location) fetched from an external API.

What I’m Trying to Do:

  • Modify Existing Email Template:
    I want to add a new box to our current digest email that will display job listings.
  • Plugin-Based Approach:
    My idea is to create a plugin that retrieves job data from the API and inserts this information into the email template. I’ve seen that some areas of these emails can be edited via the UI, which led me to believe it might be possible to modify the underlying template files through a plugin.


The Challenge:

I’m not able to access these template files from within the plugin. This brings up a couple of questions:

  1. Accessing Template Files:
    Is it possible to access and modify these email template files using a plugin? If so, what’s the recommended approach?
  2. Alternative Solutions:
    If accessing the files directly isn’t feasible, are there other methods or best practices for injecting custom data (like our job listings) into the digest email?

I appreciate any insights, experiences, or suggestions you might have regarding this approach. Thanks in advance for your help!

1 Like

Some extra questions would be if a plugin for example could create/edit this file user_notifications.digest.custom.text.below_popular_topics? I’m using a self-hosted Discourse instance in docker

In general, you can do anything in a plugin. There is no sandbox to shield plugins from a protected core.

The problem is more about learning how to do it and implementing it in a way that survives updates.

You should move this inquiry to Dev.

3 Likes

user_notifications.digest.custom.text.below_popular_topics this is a key for discourses i18n system. In the code the appropriate translated string will be fetched from database / configuration.

My gut feeling is, that you should search for another way to implement your desired behavior, as to regularly change this text (which you would have to change for every used user language on your forum).

One would be to extend

to include your content.

1 Like