I have the code below in my configuration section of my post function.
The mail.setFrom and mail.setFromName both work but the mail.setBcc doesn't.
Its worked with a string directly into this function but doesn't like when I pass a variable
mail.setFrom("email@domain")
mail.setFromName("ABC Mailbox")
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.component.ComponentAccessor;
def customFieldManager = ComponentAccessor.getComponent(CustomFieldManager)
def RECIPIENTSCF = customFieldManager.getCustomFieldObjectByName("Recipients")
def String RECIPIENTSBCC = RECIPIENTSCF.toString()
mail.setBcc(RECIPIENTSBCC)
return true
Hello
Since you wrote Its worked with a string directly into this function but doesn't like when I pass a variable , probably your variable RECIPIENTSBCC has incorrect format
Have you tested what exactly your variable RECIPIENTSBCC returns ?
See this article https://community.atlassian.com/t5/Jira-questions/Add-Bcc-to-custom-email-via-post-function/qaq-p/626373
The article listed (I've seen this before) shows the string entered directly.
As this is all contained in the configuration section, there is no output there so I passed it using the config mappings to the email template so I could print the contents and also get the type. It confirmed it was a string class
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think something is wrong with this string
def String RECIPIENTSBCC = RECIPIENTSCF.toString()
I created small script in console and it works, try it.
import com.atlassian.mail.Email;
import com.atlassian.mail.server.MailServerManager;
import com.atlassian.mail.server.SMTPMailServer;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.mail.Email;
import com.atlassian.mail.server.MailServerManager;
import com.atlassian.mail.server.SMTPMailServer;
MailServerManager mailServerManager = ComponentAccessor.getMailServerManager()
SMTPMailServer mailServer = mailServerManager.getDefaultSMTPMailServer();
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
String currentUserEmail = currentUser.getEmailAddress();
String cu = currentUser.getName();
String cuMail = cu+'@gmail.com';
Email email = new Email(currentUserEmail); //address TO
email.setSubject('some subject');
email.setMimeType("text/html")
email.setBody('some body');
email.setBcc(cuMail) //address BCC - gmail
mailServer.send(email);
email was sent to "currentUserEmail" and "cuMail" addresses
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.