The JITL jobs JSSmtpMailClientAdapter and SmtpMailMonitor are included since JobScheduler Release 1.5.3253.
These job is now without a documentation. It is useful for sending emails.
It contains all parameters like the JobSchedulerManagedMailJob.

SmtpMailMonitor

SmtpMailMonitor can used for a pre- or post-processing.

Example job using com.sos.jitl.mail.smtp.SmtpMailMonitor:

<job>
    <params >
        <param  name="MailOnSuccess_host" value="my_smtp"/>
        <param  name="MailOnSuccess_subject" value="%SCHEDULER_JOB_NAME% has run successfully"/>
        <param  name="MailOnSuccess_body" value="%SCHEDULER_JOB_NAME% has run successfully"/>
        <param  name="MailOnSuccess_to" value="mymail@address.com"/>
    </params>

    <script  language="shell">
        <![CDATA[
echo foo
        ]]>
    </script>

    <monitor  name="sendMail" ordering="0">
        <script  language="java" java_class="com.sos.jitl.mail.smtp.SmtpMailMonitor"/>
    </monitor>
    <run_time />
</job>

For this job you should use prefixes "MailOnSuccess_", "MailOnError_" and "MailOnJobStart_".

  • Prefix "MailOnJobStart_" for sending mail before the job runs
  • Prefix "MailOnSuccess_" for sending mail after the job has run successfully
  • Prefix "MailOnError_" for sending mail after the job has run with an error

For each prefix you can specify e.g. different recipients.

Example for prefix MailOnSuccess_

You want that a job should sends a mail in the case of an error in the normal way via the JobScheduler mail notification.
This mail has the task log as attachment.
Further you want a success mail but without the task log, so deactivate the mail via JobScheduler (see <settings> in the following example) and
specify some parameter with the "MailOnSuccess_" prefix.

<job>
  <settings>
    <mail_on_error><![CDATA[yes]]></mail_on_error>
    <mail_on_warning><![CDATA[yes]]></mail_on_warning>
    <mail_on_success><![CDATA[no]]></mail_on_success>
  </settings>
  <params>
    <param name="host" value="my_smtp"/>
    <param name="MailOnSuccess_to" value="mymail@address.com"/>
    <param name="MailOnSuccess_body" value="%SCHEDULER_JOB_NAME% has run successfully"/>
    <param name="MailOnSuccess_subject" value="%SCHEDULER_JOB_NAME% has run successfully"/>
  </params>
  <script language="shell">
    <![CDATA[       
exit 0       
    ]]>
  </script>
  <monitor name="process0" ordering="0">
    <script java_class="com.sos.jitl.mail.smtp.SmtpMailMonitor" java_class_path="" language="java"/>
  </monitor>
  <run_time/>
</job>

JSSmtpMailClientAdapter

Example job using com.sos.jitl.mail.smtp.JSSmtpMailClientAdapterClass:

<job>
  <params>
    <param name="subject" value="Test-Mail"/>
    <param name="body" value="This is the body"/>
    <param name="to" value="myMail@address.com"/>
    <param name="host" value="my_smtp"/>
  </params>
  <script  language="java" java_class="com.sos.jitl.mail.smtp.JSSmtpMailClientAdapterClass"/>
  <run_time/>
</job>

Example for substitute parameters

The can substitute its parameters with other parameters.
We assume that we have a job chain with two jobs. The first job transfers files and if the first job has an error than the seconds job starts to send an email. Otherwise the job chain ends after the first job. The body of the email should have the error of the first job.
The first job writes its last error in a post-processing into the order parameter with the name last_error and the mail job has a parameter

  <param name="body" value="ERROR: %last_error%"/>

for the body. Then the value of the last_error parameter is substituted into the body parameter.

Configuration of the job chain

<job_chain orders_recoverable="yes">
  <job_chain_node error_state="mail" next_state="success" state="100" job="jade"/>
  <job_chain_node error_state="error" next_state="error" state="mail" job="sendMail"/>
  <job_chain_node state="error"/>
  <job_chain_node state="success"/>
</job_chain>

Configuration of the first job for file transfer

<job order="yes" stop_on_error="no" title="API Job for JobScheduler Advanced Data Exchange">
  <settings>
    <mail_on_error><![CDATA[no]]></mail_on_error>
  </settings>
  <description>
    <include file="jobs/jadeJob.xml"/>
  </description>
  <params>
    ...
  </params>
  <script java_class="sos.scheduler.jade.JadeJob" language="java"/>
  <monitor name="setLastError" ordering="0">
    <script language="javax.script:rhino"><![CDATA[
            
function spooler_process_after(spooler_process_result) {
	spooler_task.order().params().set_var('last_error',spooler_log.last(2));
	return spooler_process_result;
}
            
        ]]>
    </script>
  </monitor>
  <run_time/>
</job>

Configuration of the second job for sending mails in the case of an error

<job order="yes" stop_on_error="no" title="Send Mails">
  <params>
    <param name="subject" value="Test-Mail"/>
    <param name="body" value="ERROR: %last_error%"/>
    <param name="to" value="myMail@address.com"/>
    <param name="host" value="my_smtp"/>
  </params>
  <script java_class="com.sos.jitl.mail.smtp.JSSmtpMailClientAdapterClass" language="java"/>
  <run_time/>
</job>