Customizing email templates
Email templates define the content and layout of the emails that are sent using The Email Button and the Email Screen, as Email Notification Schemes or as Workflow Post Function, all of which you can configure with your custom templates. To manage templates, do the following:
1. Go to Templates under the EMAIL CONTENT menu item of the Outgoing Mails configuration tab.
2. Click on Add to create a new template or click on the three dots and choose Edit to modify an already existing template.
Templates may contain static and dynamic content related to issues, projects and users, such as:
- Issue fields
- Custom fields
- Worklog details
It is possible to build templates from scratch, and there are predefined template themes that help to get started with custom templates.
Themes help you to build your own templates for various goals. Click the Add button to add new templates from themes.
This theme is used for adding templates that render all issue fields, including custom fields.
This theme is useful for notifications on events that contain comments, e.g. when an issue is commented, or a transition is executed.
This theme focuses on highlighting changes made to an issue.
This theme gathers worklog information. It is useful for notifications on worklog-related events.
An empty theme for starting a template from scratch.
Email Templates may be built using using Apache Velocity Markup. Aspects to consider:
- Basic Settings
- HTML Template
- Text Template
Category: Emails are grouped into categories. Enter any text, and a category will be automatically created if doesn't already exist. There are special categories for special uses, for instance the responses. By default, templates in this category can be selected as a canned response on the Email Screen.
Subject templates are part of an Email template. They are used for generating the final subject of the emails sent using this template. The Subject template can contain static text and dynamic content, such as issue fields and custom fields.
The $!mailSubject variable is replaced by the subject you enter in the Email Notification Schemes or Workflow Post Function.
When you send a manual email, the Subject Template is used for generating the subject in the The Email Button and the Email Screen. The subject you enter in the email screen is not modified further by the email templates when the email is sent.
HTML Template is used when an HTML email is sent using this email template. The HTML body may be combined with HTML and Apache Velocity Markup to give templates a customizable look and layout.
The HTML template may be developed using a WYSIWYG editor. With this editor everyone can develop templates without HTML coding experience.
The Rich Text editor allows users to apply formatting, add tables, images, links, preview the template and edit content in full screen.
HTML can include issue fields and custom fields, and complex structures such as:
- Issue link information
- Change history
To edit HTML directly, open the HTML Editor and make changes to the source code of the template.
Email This Issue can embed an image targeted by a URL on an
<img>tag level. This way you can send out attachments of the issue, and the recipient does not need to connect and create a Jira user account to see the attachment.
To allow this feature, add the
data-embed="true"attribute to the
<img src="https://www.meta-inf.hu/download/attachments/35749899/icon_product_jeti.png?version=1&modificationDate=1524212907169&api=v2" data-embed="true">
The Text Template is used for sending pure text emails with this email template.
The Text Body part can also contain issue fields, custom fields and the same set of complex structures as the HTML Body.
Field Picker is a dropdown list of all issue fields and custom fields. When a field is selected, a tiny popup dialog opens with the template code fragment needed to render the value of the field in the email. Click the button in the dialog to add the code to the cursor position.
The Field Picker is available for Subject Template, HTML and Text Body templates.
The following is a list of variables that are available in the email templates.
The current user sending the email
Renders the full name of the current user.
The email subject entered manually in the subject field on the manual email screen, notifications or workflow post functions. In case of a Send auto reply action this will represent the subject of the original email.
The email body entered manually in the Body field in the manual email screen, notifications or workflow post functions.
Add this variable to all templates to render an email body entered by users. In case of a Send auto reply action this will represent the body of the original email.
The Issue object with all available fields. The email is being sent in relation to this issue.
Renders the issue summary in the template.
The base URL of the Jira Cloud site. Useful to add links to Jira screens or operations.
It is a simple String value you can use in building links.
The issue event if the email is being sent as an event notification.
The comment the user enters during the operation. E.g. when editing the issue or executing a workflow transition.
Renders the comment.
The changelog holding information about all fields changed during the operation. Old and new values are available.
Renders the changelog in a readable structure.
The worklog object holding details of the worklog entered or edited.
Renders the worklog details.
The email definition object holding all recipients, the subject and body, the issue event and the comment details.
Returns the list of attachments being added to the email.
A formatted date representing when the original email was processed by Email This Issue.
Available only in Reply/Reply all/Forward for an email.
Prints the when the email was processed by Email This Issue.
String helper methods
returns true if the issue summary is empty or null.
prints the labels separated by comma.
The support object useful in templates. A constantly enhanced object, that will receive more and more methods.
The following is the list of macros that are available in the email templates.
According to Atlassian's announcement, the 'Epic Link' custom field will be deprecated as of 31th May 2022.
As a consequence, exisiting macros utilizing the 'Epic Link' value (usually in a form of
#renderCustomField($!issue 'customfield_10014'- however, the custom field ID can vary per site) won't work after this deadline.
Please, review and consider replacing your old macros with any of our new offerings (
Due to some known limitations in hierarchy level retrieval for custom issue types introduced in Advanced Roadmaps (verified by Atlassian in this community announcement), the
#renderParentmacro currently does not work as expected for higher hierarhy levels than that of Epic (1). E.g.
#renderParent($!issue, 2)will not render a parent having 'Initiative' issue type (hierarchy level 2).
A generic, multi-purpose comment rendering macro.
Renders a link to the portal with a custom text.
Renders a link to the request with a custom text.
Renders all comments (both public and internal).
Renders the changelog in a readable structure.
Renders the public comments.
Renders the public comments in reverse order.
Renders the value of the custom field as displayed in Jira.
Renders the last comment of the issue.
Renders the parent issue of the issue passed as parameter, only if the hierarchy level of the parent issue is higher than or equal to the specified hierarchy level.
Hierarchy levels of some known issue types:
Renders the parent issue of the issue passed as parameter, only if the parent issue is an Epic.
In this regard, it can be considered as a replacement for the former 'Epic Link' custom field renderer.
It is possible to add certain text to a URL link in a template. Open the template in its raw HTML editor form and use the following code:
#set($url = $issue.getCustomFieldValue('customfield_12345').value) <a href="$url/go" target="_blank">$url/go</a>
Make sure to use the correct
customfieldID as shown in the following example:
Templates offer a handful of operations under the three dots.
Opens the Test Template dialog.
Opens the template editor screen with a copy of the current template.
Opens the template editor.
Deletes the template from the system
While developing a template it is necessary to validate the look, layout and content the template renders. For the HTML Body you can use the rich text editor's Preview function to check the layout and content, but the best way to validate whether a template is correct is using the Test operation. It allows you to enter an issue key and send yourself an HTML or Text formatted email.
Once the email was sent, verify in your email app whether the content and layout was according your expectations.