Add custom Mail Headers via PostFunction notifications

Since 1.9.16

Scenario

You want to tag outbound mails generated by the JEMH Post-function with additional mail headers.  For example:

X-JEMH-ADHOC-PF-issue-key: TEST-1

Step-by-step guide

A new section has been added in the JEMH Post-function edit screen, it provides access to a velocity script that is rendered to enable the addition of specific mail headers and values:

As with similar template fields when a Template Issue is defined as the Preview Context at the top of the page, a preview icon becomes available under the editor (), this allows you to see the rendered output as text.  The output doesn't get used and is there only for diagnostics, whilst the script is in development.

In addition, the TEST button at the top of the Post-function screen will also use the current editor content when generating a test notification (e.g. to static recipient you have specified in the To: section) and will set mail headers as defined.

Example template script

#set ($theValue = "$issue.getKey()") Using value $theValue $jemhUtils.addMailHeader('PF-issue-key', "$theValue")

When previewed, will show the text part of what’s left:

 When the TEST button is used, the resulting email will have the headers specified, prefixed with X-JEMH-ADHOC-PF-

Subject: PPLANDY (TEST-1) ... MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_31_1215082462.1462892642152" X-JIRA-FingerPrint: 20f95f7a8e4e78c076cec26130f3f600 Auto-Submitted: auto-generated X-JEMH-ADHOC-PF-issue-key: TEST-1 <------------------------------------------------------- New **PREFIXED** Header here X-adHocSentByJEMH: true Precedence: bulk ------=_Part_31_1215082462.1462892642152 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable hello matey TEST-1 ------=_Part_31_1215082462.1462892642152--



Since 2.3.6, we also add a new method and enabled these to be used within IssueEvent TemplateSets also.

That will create:

SINCE 3.3.48
The addRawHeader method can also be used in Adhoc notification TemplateSets, for use in PostFunctions and Adhoc notifications.

Related articles