How change Trac to send custom html emails?

90 views
Skip to first unread message

Aikido Guy

unread,
May 17, 2021, 3:52:18 PM5/17/21
to Trac Users
Hi!

I have written a few simple custom plugins for Trac that all meet my simple needs up until this point. However, now I'm reaching a limit of sorts...

I understand that Trac 1.4.2 uses Jinja2 templates and that I can edit those templates in order to alter the contents of the outgoing email. However, I find the templates hard to read and hard to maintain; given that I do not know (nor have the time to deeply learn) Jinja2 templates.

My situation...

I have a python cron job that runs weekly and collects ticket information from a few Trac projects. It uses a static html header and static html footer; both in their own files. This allows me to both easily improve the header/footer over timeor swap them out for something else entirely.

What I'm looking for...

I'd like to make use of my static header/footer files and change the email notifications coming out of Trac from plain text to html. I'd also like to modify the contents of the outgoing email in order to simplify the contents so that when a ticket is modified a very simplistic email is sent.

I imagine that it is best to create a custom python plugin. If so, what interface(s) would be best for me to implement and what should I do to turn off the Jinja2 email template? If not, what might be a better solution?

Any and all thoughts to help me build a custom (simple) email would be very much appreciated!

Kindly,
Aikido Guy

PS I've been using Trac for quite a few years and think it is great! A job well done in my view! Thank you!

RjOllos

unread,
May 17, 2021, 3:57:48 PM5/17/21
to Trac Users

Aikido Guy

unread,
May 17, 2021, 4:46:30 PM5/17/21
to Trac Users
Interesting! I will definitely look into this! Thanks!

Aikido Guy

unread,
May 18, 2021, 4:36:31 PM5/18/21
to Trac Users
On Monday, May 17, 2021 at 4:46:30 PM UTC-4 Aikido Guy wrote:
On Monday, May 17, 2021 at 3:57:48 PM UTC-4 RjOllos wrote:
On Monday, May 17, 2021 at 12:52:18 PM UTC-7  Aikido Guy wrote:

What I'm looking for...

I'd like to make use of my static header/footer files and change the email notifications coming out of Trac from plain text to html. I'd also like to modify the contents of the outgoing email in order to simplify the contents so that when a ticket is modified a very simplistic email is sent.

PS I've been using Trac for quite a few years and think it is great! A job well done in my view! Thank you!
Ryan
 
Any idea if someone will put TracHtmlNotificationPlugin on pypi? I did a search of pypi but (sadly) did not find one...

Kindly,
Aikido Guy

RjOllos

unread,
May 18, 2021, 4:59:44 PM5/18/21
to Trac Users
Do you just wish to "pip install" it? You can pip install directly from SVN:

Ryan 

Aikido Guy

unread,
May 18, 2021, 7:45:40 PM5/18/21
to Trac Users
On Tuesday, May 18, 2021 at 4:59:44 PM UTC-4 RjOllos wrote:
Was hoping for pypi because I download to an external hard drive and then carry it over to my air gapped computer to install...

RjOllos

unread,
May 18, 2021, 7:51:53 PM5/18/21
to Trac Users
Jun hasn't been publishing his plugins to PyPI. As a workaround:

$ svn co <repos URL and path> <local path>
$ cd <local path>
$ python setup.py bdist_wheel

Wheel will be in dist/ directory.
 

Aikido Guy

unread,
May 18, 2021, 8:21:34 PM5/18/21
to Trac Users
On Tuesday, May 18, 2021 at 7:51:53 PM UTC-4 RjOllos wrote:
I now have TracHtmlNotificationPlugin-0.12.0.2-py2-none-any.whl in hand... will try it out! Much appreciated

Aikido Guy

unread,
May 22, 2021, 3:57:42 PM5/22/21
to Trac Users
I just realized that my situation is not exactly as I described... oops!

I need to have a Content-Type:multipart/alternative with one part plain text and one part html... where the html part is Content-Type:multipart/related.

With the TracHtmlNotificationPlugin will I have control over the Content-Type?
- Or would it be better to read the source code and modify for my needs?

Perhaps my original thought of creating a plugin is the simplest and most direct approach in this case... I just need the plugin listening/triggering on the right things (based on the notifications)... I can see I'll probably have to dig into code...
Reply all
Reply to author
Forward
0 new messages