Project

General

Profile

Actions

Feature #38353

open

Custom templates for email notifications

Added by Jouri Mamaev over 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Email notifications
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

Currently email notifications is hardcoded into soources but they are not intuitive and non-usable for automation.
I want to have possibility to create filters in my mail client to sort different notifications using different rulles.

It will be nice to have customizable mail templates for subject and body in some future releases but for now I made next changes to have this for now:

  • I added some templates in localization file looking like:
  # project - project name
  # tracker - tracker name
  # id      - issue id
  # status  - issue status
  # subj    - issue title
  # from    - user made changes
  # to      - assigned to
  mail_subject_issue_new: 'ISSUE NEW: by "%{from}" for "%{to}" %{status} in "%{project}": %{subj}'
  mail_subject_issue_update: 'ISSUE UPDATE: by "%{from}" for "%{to}" %{status} in "%{project}": %{subj}'

  # no args
  mail_subject_test: 'Remine test message'
  • Changed code in "Redmine\app\models\mailer.rb" to use them like this:
    s = l( "mail_subject_issue_new", 
           project:    issue.project.name, 
           tracker:    issue.tracker.name, 
           id:         issue.id, 
           status:     issue.status.name, 
           subj:       issue.subject,
           from:       issue.author.name,
           to:         issue.assigned_to.name )

    mail :to => user,
      :subject => s

Now I have possibility to easy change subject templates as I need.

May be you found this way to implement this feature easy enought to add such changes.

In attachments both changed files.
All based on current trunk version and works on:

 Redmine version                5.0.5.stable
  Ruby version                   2.7.6-p219 (2022-04-12) [x86_64-linux]
  Rails version                  6.1.7.2
  Environment                    production
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                sendmail

Files

mailer.rb (29.6 KB) mailer.rb Jouri Mamaev, 2023-03-14 16:54
ru.yml (105 KB) ru.yml Jouri Mamaev, 2023-03-14 16:55

No data to display

Actions

Also available in: Atom PDF