Mail Handlers in Jira provide basic functionality to create issues or comments from emails. In most cases, it's out-of-the-box native functionality is too limited.
Email This Issue Mail Handlers add a lot more to this, in order to implement sophisticated email processing:
Initialize issue fields from email content
Execute workflow transitions
Filter emails depending on content (e.g. spam)
Save Senders and Recipients to custom fields
Content splitting on multiple regular expressions
Send auto-reply emails
Configure Classic Mail Handlers
Classic Email This Issue Mail Handlers are composed of two components. The two basic steps to configure a mail handler are:
Adding a Mail Handler in Jira's Incoming Mail Page to hook into the Jira API that passes the downloaded email messages to the handlers
Adding a Mail Handler Context in Email This Issue to fully configure the rich functionality that comes with the addon
The handler type must be set to Email This Issue Mail handler in Jira. Below is an example for Jira's Incoming Mail Handler with Email This Issue Mail Handler type:
Mail Handler Contexts
Mail Handler Contexts just like any other "Contexts" in Email This Issue are used to add configuration in a flexible way depending on Project and Issue Type. You can define "broad" contexts that are applied to all projects and/or issue types (in this case, leave the project and/or the issue type fields blank).
Mail Handler Contexts are used in conjunction with the Email This Issue Mail Handlers. If you set up the handler to create issues in the project "MyProject" of issue type "Bug", there must be a Mail Handler Context configured to match this combination, e.g. a Mail Handler Context configured with project "MyProject" or issue type "Bug" or both.
Mail Handler Context Attributes
Project: to which the context applies. If left empty, context applies to all projects. Issue Type: to which the context applies. If left empty, context applies to all issue types.
Email Processing Strategy: Determines how Email This Issue Mail Handler processes incoming emails.
There are various strategies available out-of-the-box:
Create Or Comment Issues: either create a new issue or comment on it. It supports Split Regex (see below)
Create Or Comment Or Link Issues: either create a new issue or comment it if the issue matches the given JQL criteria, otherwise Create a new issue and link it. It supports Split Regex (see below).
Always Add Comments: find a related issue for each email and if found, comment it. It supports Split Regex (see below)..
Always Create Issues: create new issues for all incoming emails.
Service Management Create or Comment
Create Issues or Email Log: No comments will be added.
Handler actions (available for all the above strategies):
Executes workflow transition on issues: if enabled, the mail handler executes a workflow transition on the issue (read on for more information).
Initializes Issue Fields: if enabled, the mail handler looks up a Field Context and applies its field rules to initialize issue fields.
Overrides Default Issue Lookup: if enabled, the mail handler looks up a Field Contextand applies its issue lookup field rules to find the issue that can be associated with the incoming email.
Filter incoming emails: If enabled, the mail handler looks up a Field Contextand applies its filtering rules to the email.
Acknowledge Incoming Emails
Event: An issue event that is fired for each incoming email that the mail handler processes (read on for more information).
Acknowledge New Issues: If an email template is selected here, it will be used to generate auto-acknowledge emails when a new issue is created from an email.
Acknowledge New Comments: If an email template is selected here, it will be used to generate auto-acknowledge emails when a new comment is added to an issue from an email.
Senders and Recipients
Sender Name Field:
User Recipients: This attribute determines how the mail handler should treat users recognized as recipient email addresses:
Add to watchers: save as watchers in the issue
Save to multi-user picker field: save them in the selected user picker field
Treat as email addresses: treat them as email addresses and save the email addresses in the recipient fields (see below)
Recipient field (To): The custom field selected here will be used to store email addresses of the email's TO recipients
Recipient field (Cc): The custom field selected here will be used to store email addresses of the email's CC recipients
Email Address Exclusion: Email addresses (one per line) entered here are not saved in the sender or recipient fields (useful to save the mail handler address here to avoid mail loops). Supports regular expressions, to ensure your email address exclusion will not run into problems. Include (?i) at the beginning of the email address for safety.
Split Regex: Regular expressions (one per line) entered here are used to split the email body by a delimiter (optionally the original incoming email as well). See more details below.
External Email Senders: Specify how to treat emails sent from email addresses not registered as users in Jira. Options are to accept the mails for processing or to ignore (leave in the mailbox) these emails. If you want to prevent the situation that practically anyone could pollute your Jira instance by sending emails, simply set this option to Ignore.
Jira Mail Strategy: Specifies how to treat emails sent from the current or another Jira instance. Options are available to accept or ignore these emails.
Ignore Issue ID in Email Headers: By default, Email This Issue checks for the "In-Reply-To" and "References" email headers for Jira IDs if no issue keys appear in the email subject. If such an issue ID is found, it comments on the issue.
By enabling this option you can override the default behavior and make Email This Issue ignore these email headers. It can be useful to prevent confusion when an email sent from Jira is replied or forwarded back to Jira. In such cases, the seemingly unrelated issues may be commented on. If this checkbox is turned on, Email This Issue will only use the email subject and its own Issue Lookup Field Rules to process emails but will ignore the invisible email headers.
Split Regex Support
Email This Issue Mail Handler supports regular expressions to split the email body into new content and original messages and import only the new content. See this our tutorial and the Jira documentation for more details on this topic.
Multiple regular expressions can be entered in the Mail Handler Context.
Split regex support works the same way as Jira's but Email This Issue supports multiple expressions not only one expression.
An example regex that many users successfully use is:
/\s*From:|___.|On .wrote:|----Orig.|On .(JIRA)./
Email Processing Strategy
As written above: if you configure Email This Issue Mail Handler in the Incoming Mail section of Jira's Administration page, you must add a corresponding Mail Handler Context to fine-tune your mail handler.
A fully configured mail handler example is this:
HTML Content Preserved with Inline Images
The Email This Issue Mail Handler retains the HTML layout and content of the incoming emails including inline images. Send an HTML formatted email to Jira and see the original content and layout in the issue.
Execute transitions on issues
The Email This Issue Mail Handler can execute a transition on the issue that is associated with the email that is being processed.
The transition to execute is identified by a transition property called jeti.on.email.transition. Add this property to the transitions in the statuses of the workflows, set its value to "true". Email This Issue executes the first transition that has this property in the status the issue is in. You must also enable the "Execute transition" attribute in the Mail Handler:
Example Use Cases when to Use This Feature
Use Case #1:
Email This Issue mail handler is processing an email that is associated with an Issue that is Closed. Email This Issue besides adding a comment to the issue may also execute a "Reopen" transition to reopen the issue for further investigation.
Use Case #2:
Email This Issue is processing an email and creates a new issue in status Open, and after the issue is created it executes a transition to move the Issue to a new status called "Raised via email".
Email This Issue Mail Handler skips processing emails sent from blacklisted domains or email addresses. Items on the blacklist are regular expressions. If the sender's email address matches any of the regular expressions, the email is not processed.
If you configure the Mail Handler in Jira Administration / Incoming Mails with the forwarding email option, then Email This Issue will forward the skipped emails to this address.
The blacklist is maintained in the Configuration tab of the Email This Issue Admin screen:
Fallback to Default Reporter
Email This Issue Mail Handler falls back to the Default Reporter when Jira users who send an email do not have permission to create or comment on the project. Jira would simply skip these emails, while Email This Issue imports them with the default reporter. The default reporter is an appointed user account (real or technical) who is an agent on the project and has all the right permissions to create issues/ add comments.
Email This Issue Mail Handler can fire an event when it processes an email:
Define a custom event in Jira Administration, e.g. "Email Processed" (this is optional, you can use a system event too just like on the above image)
Edit your Mail Handler Context and select "Email Processed" in the Mail Handler Event field
Configure your Email This Issue Event Notifications for "Email Processed" with recipients or have a custom Event Listener to react to emails.