We want to send an email to an email alias based on the value of a custom field "Pod", e.g. if Pod =="ABC" then send mail to "myusergroup1.test.com", if Pod="DEF" then send mail to "myusergroup2.test.com. We are using the cloud version of Jira.
Is there a similar example of this done via ScriptRunner?
Hi Steven,
This is a script snippet on sending email from Groovy using JIRA SERVER, hopefully this would give you pointers to get it done for JIRA Cloud
try{
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer()
String emailAddr = "Email Address"
String emailSubject = subject
StringBuilder emailBody = new StringBuilder()
emailBody.append("Your email message")
if(mailServer){
Email email = new Email(emailAddr);
email.setSubject(emailSubject);
email.setBody(emailBody.toString());
mailServer.send(email);
}
else{
throw new Exception("Could not find Mail server object from JIRA Mail Server Manager")
}
}
catch(Exception Ex){
log.error("Could not send email")
log.error(Ex)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.