code: @SuppressWarnings({ "unchecked", "rawtypes" })
      static void sendMessage(String to, String subject, String body, String mailSessionJndiAlias)
      {
          jqmlogger.debug("sending mail to " + to + " - subject is " + subject);
          ClassLoader extLoader = getExtClassLoader();
          extLoader = extLoader == null ? Helpers.class.getClassLoader() : extLoader;
          ClassLoader old = Thread.currentThread().getContextClassLoader();
          Object mailSession = null;
  
          try
          {
              mailSession = InitialContext.doLookup(mailSessionJndiAlias);
          }
          catch (NamingException e)
          {
              throw new JqmRuntimeException("could not find mail session description", e);
          }
  
          try
          {
              Thread.currentThread().setContextClassLoader(extLoader);
              Class transportZ = extLoader.loadClass("javax.mail.Transport");
              Class sessionZ = extLoader.loadClass("javax.mail.Session");
              Class mimeMessageZ = extLoader.loadClass("javax.mail.internet.MimeMessage");
              Class messageZ = extLoader.loadClass("javax.mail.Message");
              Class recipientTypeZ = extLoader.loadClass("javax.mail.Message$RecipientType");
              Object msg = mimeMessageZ.getConstructor(sessionZ).newInstance(mailSession);
  
              mimeMessageZ.getMethod("setRecipients", recipientTypeZ, String.class).invoke(msg, recipientTypeZ.getField("TO").get(null), to);
              mimeMessageZ.getMethod("setSubject", String.class).invoke(msg, subject);
              mimeMessageZ.getMethod("setText", String.class).invoke(msg, body);
  
              transportZ.getMethod("send", messageZ).invoke(null, msg);
              jqmlogger.trace("Mail was sent");
          }
          catch (Exception e)
          {
              throw new JqmRuntimeException("an exception occurred during mail sending", e);
          }
          finally
          {
              Thread.currentThread().setContextClassLoader(old);
          }
      }
docs: Send a mail message using a JNDI resource.<br>
  As JNDI resource providers are inside the EXT class loader, this uses reflection. This method is basically a bonus on top of the
  MailSessionFactory offered to payloads, making it accessible also to the engine.
  
  @param to
  @param subject
  @param body
  @param mailSessionJndiAlias
  @throws MessagingException