Customize subject format for standard emails

At least on my instance, this currently returns tags without the brackets, which can be confusing. I’m not advocating for the brackets though, instead I’d prefer the tags to appear like:

%{optional_tags}#tag1 #tag2 #tag3


I’m really sorry to be this guy, but can someone please explain this like I’m 5? What are %{these} mysterious things?

And more importantly, can someone provide me with a before/ after example of how to properly use the email template editor in the admin settings?

“Before” being an actual email template from the settings, and “after” being an example of a properly edited template that is ready for implementation.

I would really appreciate it!

Edit: bump

Do you know how form letters say “Dear FIRSTNAME, from CITYNAME” … it is like that.

1 Like

Well, my question is how would I correctly modify?

For instance,

for this particular forum, would this exact modification be correct?:


Or would I have to keep site_name in there somewhere?

Also, why in this list of email subjects is [%{site_name}] the only one with [] around it?

[%{site_name}] %{optional_pm}%{optional_cat}%{topic_title}

BTW, is this a specific code language? I could do some research on it if I knew what I was looking for


I have learned the answer to my question!

Sharing it here would help people just like you!

1 Like


Edit: This topic offers a much more succinct summary of my ramblings below :sweat_smile:

Disclaimer – my terminology may be a little inaccurate, but I’m pretty sure I understand the basic idea. Please, correct me if I’m wrong!

Those things → %{} are called variables, and they aren’t language specific. It is basically an automated “value setting tag system” (those are my words, not an official deffinition).

The %{words_inside_the_variable_tag} are the actual variable.

When implemented, the variable tag will search the forum, and automatically replace the tag with its relevant value.

Here’s an example of what they do:

The variable tag %{site_name} as seen in this Welcome User email template

will automatically replace %{site_name} with what ever you have entered in the admin/settings/required/title field seen here:

Notice the description below the /title field – it’s pretty clear if you know what you’re looking at.

Other examples

Let’s say that a user has enabled email notifications in their profile/preferences/email settings.

The User Posted PM email template

is the template that is used to notify a user via email that they have received a personal message in the forum.

When it is time for the forum to implement this email notification, it will automatically summon the User Posted PM template, and pull the relevant values from the [PM] to replace each variable tag in the template.

So the %{topic_title} variable will automatically insert the title of the PM. The %{message} variable will automatically insert the post body of the PM. etc


Turns out, I don’t have to do anything to the variables themselves (which is what I was initially confused about).

If I’m not mistaken, the only things that can be modified in the email templates are:

  • the removing of variables
  • and customizing the plain text body of the template

Pretty neat stuff! :slightly_smiling_face:



is here a bug since Version 2.5.0?

I´ve entered as email subject %{optional_re} [%{site_name}] %{optional_pm} %{topic_title} %{optional_cat}

But only [%{site_name}] %{optional_pm} %{topic_title} works properly.
My members no longer see the categories in the subject.

Best regards


Can we verify this is still working @tshenry? Looks like we are referring to %{optional_re} and %{optional_cat}

1 Like

With the spacing instructions in the OP in mind:

I set the email subject site setting to:

%{optional_re}[%{site_name}] %{optional_pm}%{topic_title} %{optional_cat}

Here are a few different results with some context after the screenshot:

  1. Reply to a topic. A previous email for this topic did not exist
  2. New topic + plus reply. The “Re:” appears to be neglected when there is a existing new topic email. This seem correct since it’s keeping things connected.
  3. Direct reply to a user’s post within a topic. It seems to be missing the “Re:”
  4. Normal PM

The only questionable behavior is with the direct reply to a user. I’m not sure if excluding the “Re:” in this case is intentional or not.

Otherwise all seems to be working fine :+1:

@Taunusbahner is there a specific scenario not mentioned above that I should test?


I have same issue with 2.4.1 ((((( 2.3.6 worked fine…

With subject [%{site_name}] %{optional_pm}%{topic_title} %{optional_cat}
Not working %{optional_cat}, haven’t category is e-mail subject…


in the screenshot below you see my differences.

  1. Reply to a topic at version 2.5.0beta.
  2. Reply to a PM at version 2.5.0beta.
  3. Reply to a PM with older version.
  4. New Topic with older version.
  5. Reply to a topic with older version.

I have upgraded the discourse Version at the 4.3.2020.
from_version: ce83fd93bb, 15cbd16, cf24bdc, 327dd07, 54257b6 repository: /var/www/discourse, /var/www/discourse/plugins/discourse-chat-integration, /var/www/discourse/plugins/discourse-formatting-toolbar, /var/www/discourse/plugins/discourse-mlm-daily-summary, /var/www/discourse/plugins/discourse-whos-online

Today I reset the email_subject settings to no spaces, but again no categories are listed in the email subjects.


I appreciate all of the extra information. That’s always helpful!

With that said, I am having no issues with the category showing up in the email subject on the latest tests-passed version of Discourse. I even checked against restricted categories just in case there was a difference there.

I don’t think any of those plugins would be conflicting with notification emails, but if there was one to rule out it would be discourse-mlm-daily-summary since that is involving emails.

I would start by updating to the latest tests-passed version of Discourse (if you aren’t already), then if that doesn’t solve this issue, try removing the discourse-mlm-daily-summary plugin.

I also tested the following with no issues:


I don´t think that the plugin discourse daily summary do this bug.

Here is some code from the plugin. I think that uses the email template from the mailing lists.
build_summary_for(user) opts = { from_alias: I18n.t('user_notifications.mailing_list.from', site_name: SiteSetting.title), subject: I18n.t('user_notifications.mailing_list.subject_template', email_prefix: @email_prefix, date: @date), mailing_list_mode: true, add_unsubscribe_link: true, unsubscribe_url: "#{Discourse.base_url}/email/unsubscribe/#{@unsubscribe_key}", }

Here are the plugins that I have installed:
discourse-chat-integration v0.1 discourse-formatting-toolbar v3.2 discourse-mlm-daily-summary v0.1 discourse-telegram-notifications v0.1 discourse-whos-online v1.0

Alright, I’m pretty sure I know what it is. Have you edited the individual email templates? For example:


It seems that the email_subject site setting is ignored when there are any overrides to the template. It doesn’t matter if it is the Subject or the Body.

I think it makes sense that the Subject would override the email_subject site setting, but it seems a little odd that changes to the Body would as well.

1 Like


yeah that can be the key for this problem.
I have changed both template body’s.

Because we have a own footer section for our events.
That is not a big problem to change it back.
But what should I do with the footer section?

1 Like

I would leave it alone for the moment until we decide what to do about it.

@codinghorror the behavior here does seem a little odd. Do you think we should make sure that overrides to the Body section of an email template do not override the email subject site setting?


Yes, since it is resulting in support requests and is definitely an unanticipated behavior… maybe @eviltrout could assign?

1 Like

I took a quick peek and the logic seems to check if only the subject is overridden:

@riking can you add this to your list please?


I have STABLE version… And I didn’t edit email templates, probably. If only this had been done once upon a time and not by me. Is it possible to somehow reset these values to default values?
My User Posted template: