How to send email use JIRA notification service with ScriptRunner groovy script?

Roberto Saltini March 23, 2017

Hi,

I am currently able to send email using SMTPMailServer.send, however this method appears to be blocking and returning only when the email has been sent.

What I would like is for the function just to put the email in the JIRA email queue and then return immediately which appear to be the behaviour for standard JIRA notification such as "Send notification on new comment for watched issues".

Is there a way to use the JIRA standard notification engine when sending custom email via groovy SR script?

Thanks,

Roberto

3 answers

1 vote
JamieA
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.
March 28, 2017
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.mail.Email
import com.atlassian.mail.queue.SingleMailQueueItem

def email = new Email("jamie@")
email.setSubject(..)
email.setBody(..)
def item = new SingleMailQueueItem(email)
ComponentAccessor.getMailQueue().addItem(item)
0 votes
Eduard Diez
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.
September 20, 2018

do you know, how can I do in CLoud, the same?Thanks

0 votes
Niclas Sandstroem
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.
March 25, 2017

Hi Robert!

Take a look at the IssueEventManager, https://docs.atlassian.com/jira/7.1.0/com/atlassian/jira/event/issue/IssueEventManager.html

Br, Niclas

Niclas Sandstroem
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.
March 25, 2017

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events