Introduction
The MailInboxJob template can be used to read mail by an Agent.
- The job template makes use of the IMAP protocol to read mail.
- The job template can be used to specify settings from different sources:
- Connection Settings
- This includes settings such as the IMAP host, port etc.
- It is recommended to use JS7 - Job Resources for this purpose as such settings tend to use the same values for any mail inbox that should be read.
- Mail Settings
- Such settings are specific for individual mail inboxes and include e.g. the folder of the mail inbox.
- Connection Settings
- The job template can be used with a JS7 - Credential Store.
- FEATURE AVAILABILITY STARTING FROM RELEASE 2.2.0
Usage
When defining the job consider
- to invoke the Wizard that is available from the job properties tab in the Configuration view and to select the JITL MailInboxJob and respective arguments from the Wizard
or
- to specify the
JITL
job class andcom.sos.jitl.jobs.mail.MailInboxJob
Java class name, then add arguments what to send and where to send mail as explained from the below documentation.
Example
Download: pdwNotificationSOSMailPlainText.json
You can use the job wizard like this:
Explanation:
- Add an empty job from the instruction panel.
- Specify a name and a label for the job.
- Select an Agent.
In a next step invoke the job wizard that you find in the upper right corner of the job property editor. The wizard brings up the following popup window:
Explanation:
- From the list of available job templates select the MailInboxJob.
Then hit the "Next" button to make the job wizard display available arguments:
Explanation:
- Required arguments include the
to
argument to specify the recipient of mail. - Any other arguments are optional provided that a job resource is used that specifies connection details to your mail server, see below. Otherwise individual settings such as the SMTP host, SMTP port etc. can be specified from arguments.
- Select the check box provided with each argument if you want this argument to be added to the arguments of the mail job.
When hitting the "Submit" button the wizard adds the required arguments to your job that should look like this:
The job arguments can be specified
- from individual variables as offered by the job wizard.
- by use of job resources.
Use of Job Resource for Mail Settings
A number of settings for reading mail inboxes most probably carry the same values when used for different mail jobs. This includes e.g. use of the IMAP host, port etc.
- You can specify such settings individually from variables that are assigned the job's arguments, see above.
- You can specify such settings from JS7 - Job Resources that can be re-used for any number of mail jobs.
Setting up a Job Resource for Mail Settings
You can create a job resource that includes any settings required to read mail inboxes.
- For details how to set up a job resource, follow instructions from the JS7 - Job Resources article.
- Find the below example for download: eMailDefault.jobresource.json
A job resource has two parts, one being the variables that can be specified like this from the "Arguments" sub-tab:
Explanation:
- The variable names specified are selected to match use with the JITL
MailInboxJob
template. - Consider the use of variable names that start with
mail.imap.
- These variable names correspond to Java properties available with the JavaMail API. Any of the JavaMail properties can be specified.
- Find a full list of available
- general mail settings from https://javaee.github.io/javamail/docs/api/javax/mail/package-summary.html
mail.imap.
properties from https://javaee.github.io/javamail/docs/api/com/sun/mail/imap/package-summary.htmlmail.pop3.
properties from https://javaee.github.io/javamail/docs/api/com/sun/mail/pop3/package-summary.html
- Required properties include (but are not limited to):
mail.imap.host
mail.imap.port
The second part of a job resource is available with the "Environment Variables" sub-tab:
Explanation:
- Values of environment variables are assigned the corresponding variables as explained with the previous chapter.
- The purpose of the "Environment Variables" sub-tab is to propagate variables to shell jobs should you operate jobs that require such environment variables for parameterization purposes.
- Consider that the JITL
MailJob
is a job running in the Java Virtual Machine. It is not a shell job and therefore does not use environment variables.
Assigning a Job Resource for Mail Settings
With a job resource being created and deployed it can be assigned the JITL MailJob
to populate the job's arguments from the job resource like this:
Documentation
Job Documentation: https://www.sos-berlin.com/doc/JS7-JITL/MailInboxJob.xml
The MailInboxJob class accepts the following arguments:
Name | Required | Default Value | Purpose | Example |
---|---|---|---|---|
to | yes | list of mail recipient's e-mail address, multiple e-mail addresses are separated by comma | ||
| no | e-mail address used for sending mail | ||
| no | the free-text name of the account that sends mail | ||
| no | if no replies should be accepted then typically use an e-mail address such as | ||
| no | e-mail address of carbon copy recipient, multiple e-mail addresses are separated by comma | ||
bcc | no | e-mail address of blind carbon copy recipient, multiple e-mail addresses are separated by comma | ||
subject | yes | the mail subject, consider to use ASCII 7bit characters | ||
body | yes | the mail body specified as plain text or HTML depending on the content_type setting | ||
content_type | no | text/plain | a content type text/plain specifies plain text mail, a content type text/html specifies use of HTML mails. | |
encoding | no | 7bit | the character encoding of subject and body, by default ASCII 7bit is used | |
charset | no | iso-8859-1 | by default Latin 1 (iso-8859-1) is used | |
attachment | no | the path to a file to be attached, multiple files are separated by comma | ||
attachment_content_type | no | application/octet-stream | the attachment content-type typically allows binary files | |
attachment_encoding | no | Base64 | any attached files are encoded with printable base64 characters | |
attachment_charset | no | iso-8859-1 | by default Latin 1 (iso-8859-1) is used | |
mail.smtp.host | yes | the hostname or IP address of the SMTP server | ||
mail.smtp.port | no | 25 | the port of the SMTP server | |
mail.smtp.user | no | the user account to be used in case that the SMTP server requires authentication | ||
mail.smtp.password | no | the password to be used in case that the SMTP server requires authentication | ||
mail.smtp. ... | no | any additional Java properties can be used as applicable to the JavaMail package | ||
credential_store_file | no | Location of a credential store database (*.kdbx) | ./config/private/jobs.kdbx | |
credential_store_key | no | Location of a credential store key file (*.key) | ./config/private/jobs.key |
For use of the credential_store_*
arguments see JS7 - Use of Credential Store with JITL Jobs.