Chapter 15. Email support

Table of Contents

Mail in jPDL
Mail action
Mail node
Task assign mails
Task reminder mails
Expressions in mails
Specifying mail recipients
Multiple recipients
Sending Mails to a BCC target
Address resolving
Mail templates
Mail server configuration
From address configuration
Customizing mail support
Mail server

This chapter describes the out-of-the-box email support in jBPM jPDL.

Mail in jPDL

There are four ways of specifying when emails should be sent from a process.

Mail action

A mail action can be used when the sending of this email should not be shown as a node in the process graph.

Anywhere you are allowed to specify actions in the process, you can specify a mail action like this:

<mail actors="#{president}" subject="readmylips" text="nomoretaxes" />

The subject and text attributes can also be specified as an element like this:

<mail actors="#{president}" >
  <subject>readmylips</subject>
  <text>nomoretaxes</text>
</mail>
      

Each of the fields can contain JSF like expressions. For example:

<mail to='#{initiator}' subject='websale' text='your websale of #{quantity} #{item} was approved' />

For more information about expressions, see the section called “Expressions”.

There are two attribute to specify recipients: actors and to. The to attribute should resolve to a semicolon separated list of email addresses. The actors attribute should resolve to a semicolon separated list of actorIds. Those actorIds will be resolved to email addresses with by means of address resolving.

<mail to='admin@mycompany.com' subject='urgent' text='the mailserver is down :-)' />

For more about how to specify recipients, see the section called “Specifying mail recipients”

Mails can be defined in templates and in the process you can overwrite properties of the templates like this:

<mail template='sillystatement' actors="#{president}" />

More about templates can be found in the section called “Mail templates”

Mail node

Just the same as with mail actions, sending of an email can also be modelled as a node. In that case, the runtime behaviour is just the same, but the email will show up as a node in the process graph.

The attributes and elements supported by mail nodes are exactly the same as with the mail actions.

<mail-node name="send email" to="#{president}" subject="readmylips" text="nomoretaxes">
  <transition to="the next node" />
</mail-node>

Mail nodes should have exactly one leaving transition.

Task assign mails

A notification email can be send when a task gets assigned to an actor. Just use the notify="yes" attribute on a task like this:

<task-node name='a'>
  <task name='laundry' swimlane="grandma" notify='yes' />
  <transition to='b' />
</task-node>

Setting notify to yes, true or on will cause jBPM to send an email to the actor that will be assigned to this task. The email is based on a template (see the section called “Mail templates”) and contains a link to the task page of the web application.

Task reminder mails

Similarly as with assignments, emails can be send as a task reminder. The reminder element in jPDL is based upon the timer. The most common attributes will be the duedate and the repeat. The only difference is that no action has to be specified.

<task-node name='a'>
  <task name='laundry' swimlane="grandma" notify='yes'>
    <reminder duedate="2 business days" repeat="2 business hours"/>
  </task>
  <transition to='b' />
</task-node>