To automate user registration in a new Jenkins instance, I have generated a Groovy
script:
// Automatically generated groovy script -- 1463047124
j
You could try utilize Java-like code withing your Groovy script:
import javax.mail.*
import javax.mail.internet.*
def sendMail(host, sender, receivers, subject, text) {
Properties props = System.getProperties()
props.put("mail.smtp.host", host)
Session session = Session.getDefaultInstance(props, null)
MimeMessage message = new MimeMessage(session)
message.setFrom(new InternetAddress(sender))
receivers.split(',').each {
message.addRecipient(Message.RecipientType.TO, new InternetAddress(it))
}
message.setSubject(subject)
message.setText(text)
println 'Sending mail to ' + receivers + '.'
Transport.send(message)
println 'Mail sent.'
}
Usage Example:
sendMail('mailhost', messageSender, messageReceivers, messageSubject, messageAllText)