emailer_readme

Emailer Component

Introduction

Emailer component uses Java Mail 1.3.1 and Java Activation framework version 1.0.2. It provides APIs to send single and multi part email messages over SMTP protocol.

How to build

  1. First build smarfrog framework by running ant dist in core/smartfrog

  2. Build ant tasks by running ant in core/extras/ant

  3. Build Emailer by running ant in core/components/emailer

  4. Step 3 creates three jar files in core/components/emailer.build/dist/lib. Copy these jar files to core/smartfrog/dist/lib or update class path for the SmartFrog daemon so that emailer classes are available at run time.

Component Description

Table1
Attribute NameDescriptionOptional/Mandatory
toComma separated email addresses for toMandatory
ccComma separated email addresses for ccOptional
fromEmail address from which mail is being sendMandatory
smtpHostSMTP Server used to send emails over SMTP protocolMandatory
subjectSubject of the emailOptional
messageList of remote files corresponding to local files in the form of a vector.Optional
runAsWorkFlowComponentBoolean attribute to enable emailer component run as a standard workflow component. In this mode Emailer is terminated after sending the email. By default it is true.Mandatory
attachmentsVector of attachments each element denotes one file in file systemOptional
sendOnStartupFlag to indicate that a message should be sent on startup.Implicitly true when runAsWorkflowComponent is setOptional
sendOnShutdownFlag to indicate a message should be sent on shutdownOptional

Modes of Usage

Emailer component can be used in following two modes.

In this mode Emailer sends email when its life cycle method sfStart is executed and terminates after sending the email. It happens only once in the components life cycle. In this mode other components in the work-flow may not be aware of Emailer component.

For example this mode be be useful in applications installations using Smartfrog. A typical application installation has components grouped in a sequence work flow. Emailer component can be placed as last component of the sequence and can be configured to send installation log after the installation is complete.

Please go through emailer/src/org/smartfrog/services/email/exampleUsageAsWFComp.sf for sample usage.

In this mode Emailer component is used as a utility component. Other components can find its reference and invoke of sendEmail API. This utility method can be invoked as long as this component is deployed.

Remotely deployed components can also use Emailer component by getting it's reference using SmartFrog reference resolution mechanism. However in this mode components are supposed to override default attributes of Emailer component. Emailer component provides different flavors of sendEmail API to achieve this.

Please go through core/components/emailer/ src/org/smartfrog/services/email/example.sf for sample usage.

When used as a utility component, the component can also send a message on startup if "sendOnStartup" is set to true. This gives you email-on-startup semantics without the immediate termination of a workflow component.