I have a requirement to send an e-mail to another system for integration. Here I need to add a custom header (SMTP Header) with JIRA issue number, URL, status and priority. Apache Velocity Template files allows editing e-mail contents; not header. By default, JIRA adds some information (with issue id, time etc.) in e-mail headers. But I can’t add any additional information.
I read in support forums that it is possible through JIRA source code modification.Is there any free plug-in available for this modification?
Could you please help on this?
Thanks,
Subhash
Hello Subhash,
There is a improvement request already open to address this at the following link: https://jira.atlassian.com/browse/JRA-3933
If you check the comments, Matt pointed some code that he implemented to do somewhat the same of what you are trying toa ccomplish, I believe. Please see:
final Email email = createEmail(recipientEmail, sender, senderFrom, subjectForRecipient, body, mimeType); // START CHANGES // contextParams is the Velocity context for email try { TemplateIssue issue = (TemplateIssue)contextParams.get("issue"); if (issue != null) { Set<Label> labels = issue.getLabels(); StringBuffer sb = new StringBuffer(); if (labels != null) { for (Iterator it = labels.iterator(); it.hasNext(); ) { Label label = (Label)it.next(); sb.append(label.getLabel()); if (it.hasNext()) { // JIRA labels don't have spaces in them sb.append(" "); } } email.addHeader("X-JIRA-Labels", sb.toString()); log.debug("Added labels headers '" + sb.toString() + "' to email " + email); } } } catch (Exception ex) { log.warn("Unable to add labels: " + ex.getMessage()); } // END CHANGES
Also, I suggest that you vote on that ticket in order to increase it's visibility and likelyhood to be implemented.
Cheers
Hello Subhash,
There is a improvement request already open to address this at the following link: https://jira.atlassian.com/browse/JRA-3933
If you check the comments, Matt pointed some code that he implemented to do somewhat the same of what you are trying toa ccomplish, I believe. Please see:
final Email email = createEmail(recipientEmail, sender, senderFrom, subjectForRecipient, body, mimeType); // START CHANGES // contextParams is the Velocity context for email try { TemplateIssue issue = (TemplateIssue)contextParams.get("issue"); if (issue != null) { Set<Label> labels = issue.getLabels(); StringBuffer sb = new StringBuffer(); if (labels != null) { for (Iterator it = labels.iterator(); it.hasNext(); ) { Label label = (Label)it.next(); sb.append(label.getLabel()); if (it.hasNext()) { // JIRA labels don't have spaces in them sb.append(" "); } } email.addHeader("X-JIRA-Labels", sb.toString()); log.debug("Added labels headers '" + sb.toString() + "' to email " + email); } } } catch (Exception ex) { log.warn("Unable to add labels: " + ex.getMessage()); } // END CHANGES
Also, I suggest that you vote on that ticket in order to increase it's visibility and likelyhood to be implemented.
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Matt had commented that his code no longer works in JIRA 6.2.7
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.