Page tree
Skip to end of metadata
Go to start of metadata

Overview

The JavaMail framework is integrated into FIXEdge Java in the form of SMTP destination endpoints and gives the ability to send emails to external SMTP servers.

SMTP is a destination endpoint only.

Configuration properties

List of main FEJ SMTP endpoint properties:

Property

Description

Required

mail.clientsA comma-separated list of FEJ SMTP client IDsY
mail.<clientId>.hostThe SMTP server to connect toY
mail.<clientId>.portThe SMTP server port to connect toY
mail.<clientId>.usernameThe SMTP user name to connect withY
mail.<clientId>.passwordThe SMTP user's password. Optional if SMTP supports user access without a password.N
mail.<clientId>.protocolProtocol for connection to the SMTP server. 'smtp' supported.N
mail.<clientId>.subjectDefault email's subjectY
mail.<clientId>.toDefault email's 'To' comma-separated listY
mail.<clientId>.ccDefault email's 'Cc' comma-separated listN
mail.<clientId>.bccDefault email's 'Bcc' comma-separated listN
mail.<clientId>.groupsFEJ groups for routing to this SMTP endpointN
mail.<clientId>.converterRefAn instance of the email converter interface, as a reference to the Spring bean name, to convert an incoming MessageEvent to email fieldsN
mail.<clientId>.converterClass

The implementation class of the email converter interface to create a converter instance on endpoint initialization. 

An implementation based on Apache Velocity templates is used by default.

N

List of the main JavaMail properties, set with the mail.<clientId>'.properties prefix:

Property

Description

Property

Description

mail.smtp.fromEmail address to use for the SMTP MAIL command. This sets the envelope return address.
mail.smtp.authIf true, attempt to authenticate the user using the AUTH command.
mail.smtp.socketFactory.portSpecifies the port to connect to when using the specified socket factory.
mail.smtp.socketFactory.classIf set, specifies the name of a class that implements the javax.net.SocketFactory interface. This class will be used to create SMTP sockets.
mail.smtp.starttls.enableIf true, enables the use of the STARTTLS command (if supported by the server) to switch the connection to a TLS-protected connection before issuing any login commands. If the server does not support STARTTLS, the connection continues without the use of TLS; see the mail.smtp.starttls.required property to fail if STARTTLS isn't supported.
mail.smtp.starttls.requiredIf true, requires the use of the STARTTLS command. If the server doesn't support the STARTTLS command, or the command fails, the connect method will fail.
templatePath to the Velocity template file for the default email converter interface. See more Template converter properties

The full list of properties can be found here.

NOTE: The FIX session can be started or stopped only if scheduling is applied. Otherwise, the session will be inactive. Refer to the Scheduler section where the session start procedure is specified.

SMTP properties example

SMTP endpoint for Gmail server

STMP properties example
# comma separated list of SMTP clients
mail.clients=smtp1

# SMTP server connection details
mail.smtp1.host=smtp.gmail.com
mail.smtp1.port=587
mail.smtp1.username=smtp-user1
mail.smtp1.password=pass1

# default Subject/To/CC/BCC values
mail.smtp1.subject=Test subject
mail.smtp1.to=<John_Doe@outlook.com, Jane_Doe@outlook.com, etc.>
mail.smtp1.cc=<cc list>
mail.smtp1.bcc=<bcc list>
mail.smtp1.protocol=smtp

# FEJ routing groups
mail.smtp1.groups=mail1-group

# Optional. Converter class or Spring reference bean name
#mail.smtp1.converterClass=com.epam.fej.smtp.TestEmailConverter
#mail.smtp1.converterRef=testEmailConverter

# additional SMTP properties
mail.smtp1.properties.mail.smtp.auth=true
mail.smtp1.properties.mail.smtp.starttls.enable=true

# Velocity template for email content
mail.smtp1.properties.template=mail_message_template.vm

SMTP endpoint for Gmail server with TLS

STMP properties to send emails from Gmail
mail.clients=smtp-gmail

mail.smtp-gmail.host=smtp.gmail.com
mail.smtp-gmail.port=587
mail.smtp-gmail.username=<user_name>
mail.smtp-gmail.password=<pass>

mail.smtp-gmail.subject=Test subject
mail.smtp-gmail.to=<John_Doe@outlook.com>
mail.smtp-gmail.cc=<cc>
mail.smtp-gmail.bcc=<bcc>
mail.smtp-gmail.protocol=smtp

mail.smtp-gmail.groups=gmail-group
#mail.smtp-gmail.converterClass=com.epam.fej.smtp.TestEmailConverter
#mail.smtp-gmail.converterRef=testEmailConverter

mail.smtp-gmail.properties.mail.smtp.auth=true
mail.smtp-gmail.properties.mail.smtp.starttls.enable=true
mail.smtp-gmail.properties.mail.smtp.host=smtp.gmail.com
mail.smtp-gmail.properties.mail.smtp.port=587
mail.smtp-gmail.properties.mail.smtp.socketFactory.port=587
mail.smtp-gmail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
#mail.smtp-gmail.properties.mail.debug=true

# Velocity template for email content
mail.smtp1.properties.template=mail_message_template.vm

Using templates for emails

If a custom implementation for the email converter interface is not defined, the SMTP endpoint uses a default one, which is based on Apache Velocity. Velocity is a Java template engine with simple but powerful syntaxes.

This converter may transform either a MessageEvent with FIX messages inside or an AppEvent if it was routed to an STMP endpoint:

Variable nameVariable typeDescription
eventMessageEventoriginal MessageEvent for converting to email.
source
AppEvent

Predefined header field. Contains the source AppEvent instance (like NewSessionEvent) if it was sent from a business rule to an STMP endpoint.

email.templateStringPredefined header field. Custom template name. Can be set via the MessageEvent#setHeader() field. 
email.subjectStringPredefined header field. Custom email subject. Can be set via the MessageEvent#setHeader() field. 

The path to the template should be defined with the template property in the configuration of the SMTP endpoint. In the case where the template is placed into the conf directory, the path can be relative:

default Velocity template definition
mail.smtp-adaptor.properties.template=mail_message_template.vm

Sample template for sending a notification about FIX message

default Velocity template definition
*** FIXEdge SMTP Notification System ***<br/>
<br/>
Notification Type: FIX<br/>
<br/>
FIX: <b>$event.getMessage().toPrintableString()</b><br/>

Sample template for sending a notification about FIX session state change

default Velocity template definition
*** FIXEdge SMTP Notification System ***<br/>
<br/>
FIX Session ID: $source.getSessionId()<br/>
New State: $source.getSessionState()<br/>
  • No labels