Sending emails from a Java application is not rocket science! But why bother if JIRA has its own APIs to do the job for
I am talking about taking advantage of the issue event management in JIRA.
We all know about the notification schemes in JIRA and how JIRA sends email to the various subscribers when an event is fired. All we need to do is to make use of this feature.
Following are the simple configuration steps needed.
Now that the template is defined and the event added, we can write the code that feeds the relevant context for the template and then fires the event. In your plugin, all you needed is a few lines of code.
How about sending it only to selected people and not depending on the notification schemes? Like the share feature in
JIRA5? i.e. send only to selected users? Replace the dispatchEvent with the following.
And that's all. The mail queue will take care of dispatching our message.
I have attached the code of a simple servlet plugin which does both the approaches at the end of this page. After installing the plugin, it can be tested by accessing the servlet. Use a valid issue key and a receiver attribute if you are not using notification scheme.
Have a good day!