docs: private String executeScript(Run<?, ?> build, FilePath workspace, TaskListener listener, InputStream scriptStream)
              throws IOException {
          String result = "";
          Map binding = new HashMap<>();
          ExtendedEmailPublisherDescriptor descriptor = Jenkins.getActiveInstance().getDescriptorByType(ExtendedEmailPublisherDescriptor.class);
          Item parent = build.getParent();
  
          binding.put("build", build);
          binding.put("it", new ScriptContentBuildWrapper(build));
          binding.put("project", parent);
          binding.put("rooturl", descriptor.getHudsonUrl());
          binding.put("workspace", workspace);
          PrintStream logger = listener.getLogger();
          binding.put("logger", logger);
  
          String scriptContent = IOUtils.toString(scriptStream, descriptor.getCharset());
  
          if (scriptStream instanceof UserProvidedContentInputStream) {
              ScriptApproval.get().configuring(scriptContent, GroovyLanguage.get(), ApprovalContext.create().withItem(parent));
          }
  
          if (scriptStream instanceof UserProvidedContentInputStream && !AbstractEvalContent.isApprovedScript(scriptContent, GroovyLanguage.get())) {
              //Unapproved script, run it in the sandbox
              GroovyShell shell = createEngine(descriptor, binding, true);
              Object res = GroovySandbox.run(shell, scriptContent, new ProxyWhitelist(
                      Whitelist.all(),
                      new PrintStreamInstanceWhitelist(logger),
                      new EmailExtScriptTokenMacroWhitelist()
  
              ));
              if (res != null) {
                  result = res.toString();
              }
          } else {
              if (scriptStream instanceof UserProvidedContentInputStream) {
                  ScriptApproval.get().using(scriptContent, GroovyLanguage.get());
              }
              //Pre approved script, so run as is
              GroovyShell shell = createEngine(descriptor, binding, false);
              Script script = shell.parse(scriptContent);
              Object res = script.run();
              if (res != null) {
                  result = res.toString();
              }
          }
  
          return result;
      }