Customizing email content in Jira Server
Jira generates emails in reaction to events using a templating engine — Apache’s Velocity. This is a relatively easy to use templating language that can pull apart java objects in useful ways. Whether it’s adding some info to the header or footer, or shuffling around the contents of your emails, you can make a number of customizations and tailor the emails to your needs.
Customizations to Velocity templates or other Jira files are not included in the scope of Atlassian Support.
Jump to...
Before you begin
Email templates in Jira Server are stored in two locations:
- Jira installation directory: Batched issue notifications
- Jira inform - batchers app: Separate issue notifications and other events
Which ones you need to retrieve depends on what kind of notifications are you looking to customize. If you’re not sure which notifications you’re using, see Different types of email notifications in Jira.
This page is for Jira Server. If you’re using Jira Data Center, you will retrieve the templates in a different way than described here. See Customizing email content.
Retrieving templates for batched issue notifications
Retrieve these templates to customize batched issue notifications.
Good to know
- You don't have to restart Jira after modifying these templates.
- The app that contains the templates will get overwritten with every Jira upgrade, and you'll need to reapply your changes. It’s good to keep the copy of the templates somewhere, so you can reapply the changes more quickly (don't just copy the whole app as its version may change).
Step 1: Retrieve the Velocity templates
The Velocity templates used for batched issue notifications are in the Jira inform - batchers app. You’ll need to extract them.
1. Find out the app version
Your Jira installation directory might have more versions of this app. Check your current version to know which file to edit later.
Go to Administration > Manage apps, and open the Manage apps page.
From the drop-down, select All apps, and search for Jira inform - batchers.
Expand the app, and check your version (in the example below, it’s 1.1.3).
2. Copy the app from the Jira installation directory
Copy the app to a separate directory. You should never edit the .jar files inside the Jira installation directory. It’s also good to keep the original JAR file in case you needed to revert the changes.
Go to <jira-installation-directory>/atlassian-jira/WEB-INF/atlassian-bundled-plugins/.
Find the batchers-<version>.jar file.
Copy the file to a separate directory.
3. Extract the template files from the app’s JAR file
The easiest way to extract the templates is to use the following command. Note that you’ll need JDK installed for it to work.
jar xf batchers-1.1.3.jar templates/email
Step 2: Edit the Velocity templates
Once you’ve extracted the Velocity templates, you can edit them directly. For more info about the templates and what you can do with them, see:
Step 3: Upload the updated templates to Jira
Testing your changes
We recommend that you test your changes in a staging environment before applying them in production. If you break the Velocity syntax, emails won’t be sent at all.
Insert the templates back into the JAR file.
jar uf batchers-1.1.3.jar templates/email
Upload the app to Jira.
Go to Administration > Manage apps > Manage apps.
Click Upload app, and upload the JAR file. The changes will be visible once the app is reinstalled. You don’t have to restart your Jira instance.
Retrieving templates for separate issue notifications (and other events)
Retrieve these templates to customize separate issue notifications, or any other notifications, like User created, Forgot Password, Contact admin, etc.
Good to know
Any changes to Velocity templates (as well as JSPs) will be overwritten following a Jira upgrade. In such a case, you will need to manually copy your modified files to the new Jira version. If the Velocity templates and/or JSPs have changed in the newer version, you will have to manually port your customizations into them (as opposed to copying these files directly over from your old Jira installation to your upgraded one).
Step 1: Retrieve the Velocity templates
Go to the following location in your Jira installation directory:
/atlassian-jira/WEB-INF/classes/templates/email/
If you're using Jira sources files, go to
jira/src/etc/java/templates/email/
instead.- Under this directory, there are three subdirectories:
html
- contains the templates used to create emails in htmltext
- contains the templates used to create plain text mail outssubject
- contains the templates used to generate the subject of the emails
Creating new email templates
- Create your new
mytemplate.vm
files in thehtml
,text
andsubject
directories, based on the existing files in those directories - Add the templates to
atlassian-jira/WEB-INF/classes/email-template-id-mappings.xml
to make them valid choices for when you are adding a new event.
Step 2: Edit the Velocity templates
Once you’ve extracted the Velocity templates, you can edit them directly. For more info about the templates and what you can do with them, see:
Step 3: Restart Jira
After modifying these templates, you'll need to restart your Jira instance to apply the changes.
Optional: Deploying Velocity templates without restarting Jira
In a development instance, you can play with picking up velocity file changes without a restart.
From <jira-install>/atlassian-jira/WEB-INF/classes/velocity.properties
:
- Change
class.resource.loader.cache
fromtrue
tofalse
- Remove the comment sign (
#
) from#velocimacro.library.autoreload=true
Making this change in production will eventually lead to Jira not serving pages along with the 'ran out of parsers' error in the log file.