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)
}
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.