Dear Jenkins users,Is there a way to send an e-mail from Jenkins Master 
using a Groovy script ?
I have an error which I don't know how to solve it:


FATAL: javax.mail.MessagingException: Unknown SMTP host: my.mail.host;
  nested exception is:
        java.net.UnknownHostException: my.mail.host
java.net.UnknownHostException: my.mail.host


The 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.'}


Thank you,
Vlad



-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/7e5c1355-25c6-45c4-a249-6560f6dd8b0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to