Scenario
To demonstrate support for many queues (and different SMTP servers) per Project.
Requirements
Minimum: JEMH 3.3.9 (Jira 8.0.0+) / EMQ 1.9.11 (Jira 7.2.x - Jira 8.9.x)
Configuration
EMQ
Setup the Event Source
Configure the Event Source to be API, this stops EMQ responding to ‘events’ from Jira, and will only respond to API calls (from JEMH):
Queues
If Queues are left with no whitelisted project, they will match all projects. Update the queue whitelist:
Once Queues refer the project, you can confirm this via the Jira Project > Notifications view:
In the above screenshot, you can see that in (1) we have no Notification Scheme selected in the project (set through Actions drop down menu top right of screenshot), this is fine, as JEMH re-picks that in its own Notification configuration. In (2) you can see all the queues that are candidates for handling notifications for this project. In (3) you can see the JEMH events (and notification scheme) that are enabled.
JEMH
We need to setup two custom field values to drive the Notification:
a) Storing the mailbox address (catchemail) in a text single line Custom Field Default
The velocity markup required to get the mailbox address that matched the Profile > Email > Catchemail is:
$jemhUtils.getCatchEmailAddress().getAddress()
b) Defining the EMQ Queue to use via a Custom Field Default value
Since JEMH 3.3.9 (Jira 8.0.0+) its possible to pick a custom field within JEMH Notification Mappings that will be used to pick the EMQ queue that should be used to deliver a message rendered by JEMH. The logic for determining that is custom velocity logic. The values should be the numeric ID’s of the queues.
Locate the queue ID’s
This is harder than it should be. We will expose this on the Jira Project > Notification summary page, but for now, ID’s can be located by Going to EMQ, and hovering over each EDIT link, and noting the ID shown by the browser at the bottom of the screen, it would be something like the following, so ID would be 2.
http://localhost:8080/plugins/servlet/emq/general-configuration#/mailConfiguration/mailQueue/2
Example Issue
Commenting on EM-1 above, will cause JEMH to render the notification, with a custom From: address defined through the mailbox from address text single line custom field. It will then pass the Email along to EMQ for processing through EMQ Queue #2.
c) Configure Notifications
Configuring Notifications needs two steps, done in order:
(1) Configure the Custom From: address custom field
(2) Enable EMQ
Once EMQ is enabled, the above config becomes hidden, but still applies. Here we pick the field we set above in the EMQ Queue custom field Selector.
Delivery
EMQ queues individually can be set to Immediate or Digested delivery. Immediate Delivery will result in the Email built by JEMH being sent ‘as is' (including custom from: address) through the nominated queue SMTP Outbound server. If Digested delivery is set, then the content of the email is extracted and stored, the custom From: details are discarded, so in this case, the Email from: address: would be re-set based on the EMQ Queue settings:
Adding a comment in the issue generates a new SMTP notification, with immediate delivery, we get a sent mail looking like: