Skip to main content
5 ways to make mail magic in Jira with ScriptRunner
Share on socials
Person holding a laptop
Jess Thompson
Jess Thompson
20th January, 2021
Jira
Data center icon
Server icon

5 ways to make mail magic in Jira with ScriptRunner

Looking for inspiration for how to automate emails related to your Jira instance? Check out these free scripts to get you started.
No matter how religiously we use Jira as an organisation, a certain amount of email communication is inevitable. Today we’re going to take a look at how you can work with email as part of your project toolbox, rather than fighting against it.
We’re also going to share with you five readymade scripts, totally free, to help you instantly supercharge your Jira mail management capabilities using ScriptRunner for Jira’s Mail Handler.
Allow users to add comments from their inboxes, automate issue creation based on email triggers, auto-create users, assign tickets and much more! Let’s go...

What is ScriptRunner Mail Handler?

ScriptRunner Mail Handler is a feature found in ScriptRunner for Jira which builds on Jira’s native mail handling capabilities to give you more flexibility and more control.
ScriptRunner Mail Handler enables you to run Groovy scripts when a message is received, letting you define both:
  • the criteria for action (which can be complex and multi-part if necessary), and;
  • what you’d like your Jira instance to do with the incoming information.
For Jira Server and Data Center, we’ve recently moved ScriptRunner Mail Handler into the main menu of the app too, to make it easier to find and start using (for those with smaller screens, search under 'More' as shown below!)
ScriptRunner for Jira's Mail Handler can now be found in both the left hand menu and the top menu, under 'More'

So what can I use it for?

Since it’s script based, this feature can be used for all kinds of automations. Not only can these automations be used to save Jira admins huge amounts of time, they can be a great way to tighten up processes to ensure nothing slips between the cracks, and to improve both internal and external service management offerings.
If your Groovy scripting skills are a little rusty or you’d like some inspiration for how you can start leveraging Mail Handler, here are some examples you can start using today, including free scripts for you to copy-paste from our Script Library.

How to customise your Jira mail management

Here’s the inspiration we promised, each with its own readymade script for you to copy and customise.

1. Create a new issue and set the assignee to CC’d user

Whilst standard Jira mail management allows you to create a new issue from an email, this script enables you to simultaneously set the ticket assignee to the first valid user who’s in carbon copy on the email (CC) in one fell swoop.
If you only want issues assigned to specific users, you can customise this script for your own organisation by defining a list of pre-approved assignees for ScriptRunner to check against. Get as specific as you need to make it work for you!

2. Add comments to issues from inbox

You may have some, ahem, Jira-resistant members of staff who insist on replying to issues they are mentioned in by continuing an email chain from their notification mail, rather than logging into Jira. 
With this script, your users can reply to the email and automatically add a comment to the issue mentioned in the subject line. Simple but effective.

3. Trigger new issue creation and assign to epic from existing issue in email body

Plans change and move, via email as much as anywhere else, but this isn’t a problem if you can build for it. With this script, you can create a new issue and automatically set the epic link based on the email content. It’ll comb the email, figure out which epic you’re working on and create a new ticket within that epic.
As with the other scripts in this post, you can customise this further to suit your requirements and handle any specific exceptions: we know that each business has its own needs. Unique and complex are two words that ScriptRunner is not fazed by.

4. Create new issue and set priority to match from email header

This is a powerful suggestion that can be used to great effect in combo with the other ideas outlined above. You can map the priority of the newly created issue in line with the priority of the email that triggered its creation. For instance, if the sender has flagged the email as high priority, you can automatically assign the corresponding issue as high priority in Jira. 
Don’t forget to outline a default option and feel free to add extra rules to determine an even more defined priority list, too!

5. Add a comment to the Service Management issue mentioned in the Mail Subject

This relates to the second script on our list but applies specifically to service management, allowing you to quickly centralise, scope and triage emerging IT or other service issues within your business.
Get ahead of your Slack/Teams notifications or the creation of 200 new support tickets by sharing instructions for anybody affected by a known issue to send an email with the ticket name in the header and detailing their experiences in the body copy! Empower your service management teams to centralise automatically, understand fully and act appropriately.
We hope this post has given you some inspiration for how these scripts could slot right into your business to start saving you some headache, or, better yet, prompt some additional ideas for how these free scripts can be tailored for your needs to remove more email triage from your day!
Feeling inspired? Share this post with your teammates!

Not using ScriptRunner for Jira yet?

Try it free today to show your team what’s possible.