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

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

2 answers

This widget could not be displayed.
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)
This widget could not be displayed.

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

486 views 3 18
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you