Send a custom email (ScriptRunner) BCC Configuration

Vivo Bandito
Contributor
May 4, 2023

Hello all,

I am attempting to create a custom email post function using the Send a custom email (ScriptRunner). One of our main requirements for this is that it sends to the blind carbon copy (Bcc). I've referenced two different scripts both with no success either individually or combined. The emails will be fail in the mail queue. 

See Linked

https://community.atlassian.com/t5/Jira-questions/Add-Bcc-to-custom-email-via-post-function/qaq-p/626373

https://docs.adaptavist.com/sr4js/latest/features/workflows/post-functions/built-in-post-functions/send-a-custom-email

Condition and Configuration

import com.atlassian.jira.component.ComponentAccessor

//set recipients from request participants

def multiSelectAddressesCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Request participants")

def recipients = issue.getCustomFieldValue(multiSelectAddressesCF)?.join(",")

 

mail.setBcc(recipients )

I have been able to test this with the "mail.setTo(recipients )" with success. Also inputting the direct email into "mail.setBcc("me@example.com" )" will not send to the Bcc but it will send to the "TO" recipient. 

Any and all help is appreciated. 

Jira Version: 8.20.12

Scriptrunner Version: 7.8.0

 

 

1 answer

1 accepted

0 votes
Answer accepted
Vivo Bandito
Contributor
May 20, 2023

I was finally able to get it going with the following script in the condition and configuration. I also needed to clear the cache in order to get it going. 

import com.atlassian.jira.component.ComponentAccessor

//set recipients from request participants

def multiSelectAddressesCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Bcc..")

def recipients = issue.getCustomFieldValue(multiSelectAddressesCF)?.collect {

    it.emailAddress

}?.join(",")

//BCC Email List

mail.setBcc(recipients)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events