Sometimes we need to schedule some mails to be sent to different groups of Jira. For example, for worklog compliance, or similar cases.

For this reason in Jira we usually create Services to do these tasks.

We cannot send mails directly to groups, but with a simple script we can obtain the mail list of members of the Jira groups (or Ldap groups) and use it to send the mail.

We can combine with some pieces of code to operate with the current DATE_TIME

Example of script to start the mail…

import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.CustomFieldType
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.mail.Email
import com.atlassian.mail.server.MailServerManager
import com.atlassian.mail.server.SMTPMailServer
import org.apache.log4j.Category
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.component.ComponentAccessor;
import java.text.SimpleDateFormat
import java.sql.Timestamp
import java.text.DateFormat
import java.util.Date

MailServerManager mailServerManager = ComponentAccessor.getMailServerManager()
SMTPMailServer mailServer = mailServerManager.getDefaultSMTPMailServer()

def bcc = "";
def groups = ["jira-software-users","jira-core-users"]
def groupManager = ComponentAccessor.getGroupManager()
def i = 0;
while ( i < groups.size()) {
	def members = groupManager.getUsersInGroup(groups[i])
    def j = 0;
    while ( j < members.size()) {
        bcc = bcc + "," + members[j].getEmailAddress();

Email email = new Email("default<>")
email.setSubject("Ethereum will dominate the world!");
def text = "Message content in HTML"


Posted by:.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s