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

David Conradie May 26, 2013

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!)

thx

3 answers

1 accepted

0 votes
Answer accepted
David Conradie June 11, 2013

Will explore a mail handler plugin

David Conradie July 23, 2013

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.

2 votes
Patrick Li
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, 2013

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.

David Conradie June 4, 2013

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?

thanks

Patrick Li
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, 2013

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.

David Conradie June 4, 2013

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.

0 votes
David Conradie June 4, 2013

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

Sharon Connell January 26, 2018

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
TAGS
AUG Leaders

Atlassian Community Events