Help with changing the subjects of notification emails

I am trying to modify the subject lines of emails sent out from my self-hosted gitea instance (v1.20.5 via docker-compose).

I am following this page in the docs: Mail templates | Gitea Documentation. I have ran gitea embedded extract --destination /data/gitea templates/mail/** and modified one of the downloaded templates and added this line at the very top:

Test Subject
---
<!DOCTYPE html>
<body>
...
</body>

And then I ran docker compose restart to restart the gitea server. But my changes to the subject line are disregarded and .FallbackSubject from the metadata context is used. I have tested and I have no issue modifying the email body, it’s just the email subject.

Any help would be highly appreciated, thanks!

I’ve played around with it a bit more, read more pages from the gitea docs and the golang’s template engine. I really doubt I am doing anything wrong here, I’m more inclined to believe this is a bug with gitea, therefore I’ve opened an issue on github here:

I have posted my issue on all of the official channels and still have got not a single word in response. Could someone please let me know if this is acknowledged?

If you put {{.Subject}} somewhere in body of mail template, does it output Test Subject or is it empty?

@jake It seems like I got nothing back. See the attached screenshot. I did restart the gitea container after modifying the template as well.

P.S:

  • The template I’m modifying is in /data/gitea/templates/mail/auth/register_notify.tmpl.
  • According to gitea help my CustomPath is /data/gitea

@jake
If I put {{.Subject}} somewhere in body of mail template. It output nothing. Seems this is a bug. I have tried 200 times and with many different way but still does not work. Please help.

Thanks,
Dicki

It is a bug, see issue filed by OP above (Cannot change email subjects · Issue #27793 · go-gitea/gitea · GitHub).

According to user on that issue,

That’s a bug. Seems like Gitea only applies this --- subject to issue related mail while others just use the default one. So our results are both reasonable now.

They create pull request Add custom subject for all kinds of mail templates by lng2020 · Pull Request #27861 · go-gitea/gitea · GitHub to solve issue, but it has not been merged yet. May be available in 1.22 or 1.23 if it does get merged, I think unlikely it will be backported to 1.21 since it is very niche.