CC mail in send custom email

I'm trying to modify the built in script "send to custom email to accept a addresses inserted into some customfield in Email CC.

how can this be done?

in this documentation he tells that i can add

Email email = newEmail("") // Set the TO address, optionally CC and BCC

some more examle? someone has modified the default script ?

3 answers

1 accepted

4 votes
Answer accepted

I had a quick peek of the API here:

The below should give you what you're after:

Email(String to)
Constructor specifying only the recipient.
Email(String to, String cc, String bcc)
Constructor including cc and bcc addresses.

Are you familiar with how to pull values from a custom field to populate the CC field?


to modify the built in script i've to hack the library then? can't i add somewhere else the script?


to modify the built in script i've to hack the library then? can't i add somewhere else the script?

hmm ... it won't be as easy as changing a single line of code if you modify the built in script. You'd also need to create an input field for the CC line similar to how the TO input field exists, and who knows how you'd modify the behavior of the plug in with your changes. If you have some programming experience, I'd suggest creating a custom script. If you have none, .. well .. see if you can borrow a programmer. here's an example of a script that I use that sends emails to certain users when all tasks for a parent issue are done. Dissect and modify if you wish:

import org.apache.log4j.Category
import com.atlassian.jira.ComponentManager
import com.atlassian.mail.server.managers.OFBizMailServerManager
import com.atlassian.mail.server.SMTPMailServer
import com.atlassian.jira.mail.Email
import com.atlassian.mail.queue.SingleMailQueueItem
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor

log = Category.getInstance("com.onresolve.jira.groovy.TicketWatcher")
log.debug ("---- Ticket Watcher script running ----")

def sendEmail = true
issue.getParentObject().getSubTaskObjects().each { t ->
	log.debug ("Analyzing $t")
	if (!t.getStatusObject().getName().equals("Done")) { 
		sendEmail = false
		log.debug ("$t is still open.  Do not send email.")

if (sendEmail) {
	// configure email
	def projectManager = issue.getProjectObject().getLead().emailAddress
	def baseURL = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
	def issueURL = baseURL + "/browse/" + issue
	def parentURL = baseURL + "/browse/" + issue.getParentObject()
	log.debug ("address: $projectManager")	
	log.debug ("base URL: $baseURL")
	log.debug ("issue URL: $issueURL")
	log.debug ("parent URL: $parentURL")
	OFBizMailServerManager mailServerManager = componentManager.getMailServerManager()
	com.atlassian.mail.server.SMTPMailServer smtp = mailServerManager.getDefaultSMTPMailServer()
	Email email = new Email(projectManager)
	email.setSubject("Ticket ${issue.getParentObject()} Requires Review")
	email.setBody("The last open task (<a href=\"$issueURL\">$issue</a>) for ticket <a href=\"$parentURL\">${issue.getParentObject()}</a> was just closed.  Please review <a href=\"$parentURL\">${issue.getParentObject()}</a> to determine if it should also be closed.")

	// send email
	SingleMailQueueItem item = new SingleMailQueueItem(email)
	try {
	} catch (Exception e) {
log.debug ("---- Ticket Watcher script ended ----")

i've duplicated the send email, and modified adding another fields.

the problem is that i need to rebuild the jar i suppose

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


244 views 0 6
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