Marcel Marcel - 8 months ago 58
Groovy Question

Sending a mail in groovy (without additional libs)

I'm writing several scripts which are shared within the company. I currently have the requirement that under some conditions a mail should be sent.

This is pretty easy by using the javax.mail.* packages which are unfortunately not part of the default library.

The scripts are shared via VCS and mostly used by business people who open them via double click. (groovy files are on their systems automatically opened with grooovy.bat)

It would be a huge effort the install the libs on all their systems. Everywhere Groovy 2.4.5 and Java 8 is configured.

Is there an easier way of sending a mail? For example by

  • loading the lib dynamically?

  • or sending the mail without the lib?

thanks in advance


You can fetch libraries dynamically with the @Grab statement, but you have to ensure that your script will be able to load the lib from a repository.