guideonce.
← All guides

Jira Service Management · Mail Handlers

How an Email This Issue Mail Handler Rule Tree Runs

A tree of conditions and actions with no try/catch, where a failed action abandons the rest and the user it runs as is chosen from the sender. A reference, with the testing and production habits.

Where this fits

The migration runbook says how to build the incoming connection and handler in order (inbound side). This post is the reference for how the rule tree behaves once built, and the habits that keep it running. The templates it feeds are in the templates post.

An Email This Issue Cloud mail handler is a tree of conditions and actions, run top to bottom against each incoming message. It has no try/catch, a failed action abandons the rest of the tree, and the user an action runs as is chosen from the sender, not from you. Those three facts explain most of the surprising behaviour.

Scope note. This is a reference compiled from Appfire's Cloud documentation, which I checked against the handler settings pages as I wrote, together with what I learned running a helpdesk handler. Where I could not find Cloud documentation, or the documentation I found was for the Server and Data Center product, I say so, and the last section lists everything inferred or untested.

How the Tree Executes

The “Runs As” Problem

The executing user is chosen from the From address, and the documentation is consistent on the rules:

SenderWho the actions run as
Maps to a Jira user (agent or customer)That user: “the Reporter for creating issues, the Author for adding comments, the user who executes transitions, and so on”
Maps to a user, but the action is not permittedThe Default Reporter, if one is set and Fallback is enabled
Not found, Default Reporter set and Fallback onThe Default Reporter
Not found, no Default Reporter or Fallback off“Execution is aborted”

Fallback to default reporter. If a handler action fails with a permission error, “the entire action will be retried with the permissions of the Default Reporter.” It is a per-handler setting and the only recovery mechanism there is.

What a portal customer can do. Appfire says that, because of Jira's permission handling, a customer “cannot update a request even if the reporter is the customer itself.” In practice a customer can raise requests, add public comments, and view requests they report or participate in. They cannot edit fields, add internal comments, move work through agent workflows, suppress notifications or manage watchers. The exact set is Atlassian's, and I did not re-verify every item.

There is no per-action “run as” in Cloud. The levers are Fallback, the Default Reporter's permissions, and the Assets macros' $runAsUserName, which applies to templates only.

What follows for the design

Guard the “issue exists” branch

Key lookup is always active and searches the whole Jira instance (see the templates post). So a customer replying to a notification from another project, or a subject that happens to contain a key-shaped string, can attach mail to an unrelated issue. Put an Issue matches query condition, for example project = HD, in front of the add-comment action, and send other matches to an ELSE.

Conditions and Actions, as a Reference

The Cloud handler has four tabs: General handler settings, Filters, Find issue, and Rules and actions. Conditions can be nested and combined into groups with AND and OR, which the newer interface “highly encourages.”

ConditionChecksNotes
Check if any of the finders fit an issueWhether a lookup found an issue (“exists” or “NOT found”)The branch condition
Check if an issue is previously created by the Mail HandlerThat an issue was created earlier in this runTargets the issue just created
Email content matchesJava regex on body, subject, a named header (case-insensitive; a missing header means false), To, Cc, To/Cc, From address, From nameRouting, such as test versus live by the To address
Issue field matchesStatus only, equals or not equalsFalse when no issue is in context
Sender has NO access to the issueBrowse Projects permission; request participants countGlobal permission if there is no issue
Sender is member of any of the groupsGroup membership
Sender is member of any of the project rolesRole in a projectAgent-by-email branches
Issue matches queryJQL on the issue in contextConfines matches to the right project
Email sender is unknownNo Jira account; a disabled account counts as unknown
ActionWhat it doesUse it when
Create issue / requestProject; issue or request type; split regexp; attachment handling; attach the original .eml. Empty bodies still create (a placeholder if Description is required)IF issue NOT found
Set field value (child of Create, Update or Transition)Field; append or overwrite; content from the email (body, subject or header, with regex groups), a manual value (empty clears on update), or participants' addresses and namesSummary, Labels
Update issueContainer for Set field value; optional “Suppress Jira's built-in notifications” (needs Administer Jira or Project)Agent-only branches, or with Fallback
Add commentSplit regexps (each as /…/, applied after conversion to wiki format); visibility (JSM internal or public, roles, groups); attachment handling; .emlIF issue exists
Send auto-replyTemplate; From address and name; sends as the Default Reporter by defaultA mail-only acknowledgement
Execute workflow transitionTransition; Set field value children. Detailed options unverifiedFor example, reopen on reply; customers usually need Fallback
Create customerCreates a JSM customerBefore adding new addresses as participants
Add to Request Participants / Add senderAdds To, Cc or From as participants, granting customer access; “does not add newly created customers” without Create customerCc'd colleagues
Save senders/recipients to fieldsStores addresses or users in custom fieldsExternal-participant tracking
Approve / Decline requestJSM approval by email. Options unverifiedApprovals

Around the tree sit Global Sender Address Filters, Attachment Filters (filename regex) and the Handler Filters on the Filters tab. Link issue and Add watchers are not documented as Cloud handler actions. Test whether Set field value accepts Watchers on your site, and use Jira Automation for linking.

Testing a Handler

The Test Handler button. I found it documented for Server and Data Center, not Cloud. Appfire's Cloud page on adding and editing handlers lists only the cog (filtering, finding issues, rules and actions), the pencil (general settings), the status toggle and delete. The Server and Data Center version lets you upload an .eml file, and Appfire says “this is an ordinary mail handler execution, therefore it is only to be used for testing purposes.” It is not a dry run. If your Cloud interface has the button, assume the same: use a test project, check the log, and delete the test issues.

Two connections, one handler

The general settings allow several incoming connections on one handler. The benefit is identical rules and no drift between test and live. The trade-offs are real: test mail creates real tickets and live notifications, lookups are site-wide, and a Create action's project is fixed per action, so the test branch needs its own Create. The recipe:

  1. Bind both connections to the handler.
  2. At the top level: IF To matches the test address, run the test-project create and comment actions. ELSE, run the live tree.
  3. After each change to the live branch, copy it into the test branch before testing.

Two traps

Reading the Incoming Mail Log

In Administration, the log can be searched by expression, key, sender or subject over 7, 15, 30 or 90 days or all time, with 10 to 1,000 results.

Category / statusMeaning
fetch email“A temporary storage status for emails just being processed”
filter email / SkippedStopped by a filter; the detail names which
execute handler / SucceededAll actions completed; shows the resolved user and the branch taken
execute handler / FailedRead the line before Last handler action failed, stop further processing

A message that is absent from both the log and the Incoming Mail Queue was never received, usually because it was read in the mailbox first.

Running It in Production

What Is Documented, Inferred, or Unverified

Status of the claims

Documented by the vendor (Cloud): execution order; child versus sibling actions; the failure message; Fallback to default reporter; how the executing user is chosen; multiple connections on one handler; the lookup order and site-wide scope; the log statuses; the monitoring, queue and backup behaviour above.

Documented for Server and Data Center only: the Test Handler button and its .eml upload; automatic retry of failed outgoing mail; the Backup and restore feature; the Large emails filter.

Inferred: that there is no try/catch (nothing documented says otherwise); the exact set of things a portal customer can do; that Link issue and Add watchers are absent in Cloud (I did not find them documented).

Options I could not verify: the detailed options of Execute workflow transition and Approve / Decline request, and whether Set field value accepts Watchers.

Not tested end to end by me: the two-connection, one-handler test recipe as written.

Closing Thoughts

Treat the tree as code that has no error handling and runs as whoever sent the mail. Keep the customer path to three things a customer can do, put a project guard in front of every “issue exists,” and keep the top level empty. Then keep a copy of the whole thing somewhere outside Jira, because the product will not.


← All guides