How to create custom email templates in JIRA?

Andrew Ting June 4, 2015

Hi,

I am trying to create a custom email template. I have modified the email-template-id-mappings.xml file as follows:

<templatemapping id="18">

<name>HR Issue Resolved</name>

<template>hrissueresolved.vm</template>

<templatetype>issueevent</templatetype>

</templatemapping>

I have created the hrissueresolved.vm file under the subject and html folders on the server. NOTE: I have not created this file under the text folder as we only use html emails.

I have added a new event called "HR Issue Resolved" to Events in JIRA. I have modified our workflow so that this event is fired when an issue is resolved.  I have restarted JIRA. When I tested our workflow, I do not receive any email.

Can anyone please help me out? Thanks!

2 answers

0 votes
William Crighton _CCC_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 4, 2015

updated answer with better questions

0 votes
William Crighton _CCC_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 4, 2015

questions:

  • JIRA version?
  • cloud or server?
  • contents of mail queue during/after you trigger event?
  • have you tested using a pre-existing template? (remove your velocity prowess from equation)
  • contents of atlassian-jira.log and the mail log (like pages of stack traces)

-wc

 

Andrew Ting June 4, 2015

JIRA 6.3.15 Server The new email template is based off the issueresolved.vm template. I know it works because if I directly modify the issueresolved.vm template and fire the "Issue Resolved" event when my issue closes, I do get an email and with the modified contents I am expecting. So I know the template is correct. Thanks.

MattS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 5, 2015

Yes, this is part of why customizing JIRA email templates is harder than it feels like it should be. Test with an unmodified copy of issueresolved,vm in hrissueresolved.vm. Make sure the transition is using your custom event and has been published. Make sure your issue is of the right type to be using the workflow. Once all that is working then start modifying the velocity template one small change at a time. You can use velocity.properties to not have to restart JIRA for every change. Then be ready to test hrissueresolved.vm at every upgrade. Are you sure you really need a new template? I generally encourage people to click on the View Issue link in email whenever I can

William Crighton _CCC_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 5, 2015

thanks Matt - I'd make that the answer

William Crighton _CCC_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 5, 2015

@Andrew Ting - also have the jira mail queue up so you can see if anything is generated to be sent. I strongly suspect that nothing is getting to the queue tho, which indicates a config problem (workflow published?) or problems in the velocity. -wc

Andrew Ting June 8, 2015

Hi All, thanks for your responses. I copied the existing issueresolved.vm and renamed it hrissueresolved.vm to eliminate any VM errors. It still doesn't work. It seems that JIRA can't pick up the mapping I've added to the email mapping xml file. It doesn't recognize it at all. I checked the mail queue and no email is coming through. So for now I've just decided to edit the existing vm template files and use an if-statement. Thanks again. Andrew.

Suggest an answer

Log in or Sign up to answer