In a custom listener triggered by incoming email, is it possible to know which mail server config created the issue?

I have a Groovy custom listener triggered on the Issue Created event.

Issues are being created by email. We have several email addresses all delivering in to the same project and issue type. Each email address is supposed to be mapped to a unique set of issue settings (assignee, watchers & some domain-specific custom fields).

Is there any way to find out in the listener code which mail server config was the creator of the incoming issue?

(This is one of the classic use cases for the JEMH plugin. I can't use that plugin, so need an alternative... would prefer not to have to write my own mail handler plugin!)


3 answers

1 accepted

0 votes
Accepted answer

Will explore a mail handler plugin

I ended up solving this in a slightly hacky way: I configured a rule on my mail server to prepend an identifer to the subject of the incoming email, depending on the address the message was addressed to. Then in the Issue Created handler (a Groovy script), extract the identifier from the ticket's summary, use it to find the table of settings appropriate for that particular address, and set as required.

Not specially elegant, but does the job.

If you are using the event object, it probably won't contain information on the incoming mail server. But if you create a simple field, and populate it with info on where it comes from

e.g. email from address A, which means it is handled by mail handler B, you can fill it with a value like Mail Server Config B. You can then get the issue object from the event, and query for the field's value to work out which config it is.

Thanks for your response Patrick. I'm a little unclear on how you're seeing the simple field being populated with information specific to the mail handler that created it? - the only fields configurable in the native mail handlers that come with JIRA are Project and Issue Type. So I can't see how I can tell JIRA to populate a field with, say, "Mail Server Config B" when the email was sent to 'address A', but (for example) "Mail Server Config D" when the email was sent to 'address C'. Am I overlooking something?


Ah, sorry, mis-read your 1st paragraph. I thought you meant you have it set up in a way where those fields are already mapped and working.

Anyway, in this case, are you able to differentiate the origin based on the reporter? i.e. each incoming email address will have a different reporter.

Hi Patrick, unfortunately I can't differentiate by reporter. Reporters are varied.

I think I'm going to have to bite the bullet and look at writing a mail handler plugin.

Thanks for your help.

Is this getting no responses because it's an incredibly dumb question or because it's an incredibly hard question? :(

Hi David - I am facing the same dilemma using Jira cloud and ScripRunner. Were you able to solve? Specifically, I would like to add a label (or component) to a newly created issue based on the email handler.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,750 views 3 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you