I would like to understand if we could use multiple To addresses in jira custom email handler.
I'm reading a CSV file and sending email to certain recipients if the conditions in other columns are met.
I could send email to one recipient but when I use multiple "To addresses", separated by comma, I get invalid email address error.
Below is my email handler function. Please help me out here.
def sendEmail(String emailAddr, String subject, String body) {
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer()
if (mailServer) {
Email email = new Email(emailAddr)
email.setMimeType("text/html")
email.setSubject(subject)
email.setBody(body)
mailServer.send(email)
}
Hi @Manjupriya
You could try to use this code for multiple recipients
import com.atlassian.mail.queue.SingleMailQueueItem
void sendEmail(String subject, String body, List<String> emailTo) {
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer();
if (mailServer) {
Email email = new Email(String.join(",",emailTo))
email.setSubject(subject)
email.setBody(body)
email.setMimeType("text/html")
def item = new SingleMailQueueItem(email)
ComponentAccessor.getMailQueue().addItem(item)
}
}
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.