Klevr Product Documentation logo

Outbound SMTP Stage

The Outbound SMTP stage allows email-based messages to be sent from Klevr Integration Hub, including with attachments.

Stage Overview

The Outbound SMTP stage allows email-based messages to be sent from Klevr Integration Hub, including with attachments.

Stage Definition File Location

All Outbound SMTP stages are defined by creating an appropriately formatted JSON definition file in the following location:

interfaces
{businessUnitCode}
{domainCode}
{integrationName}
out
smtp
{STAGE_NAME}.json

Stage JSON Definition File Format

The JSON definition file for an Outbound SMTP stage is as follows:

{
  "name": "stage-name",
  "displayName": "Brief Stage Title",
  "description": "Brief description of the stage.",
  "enabled": "$env:STATUS_<INTEGRATION_NAME>",
  "source": "source-event",
  "concurrency": 10,
  "fromEmail": "$env:SMTP_FROM_ADDRESS",
  "toEmail": "$env:SMTP_TO_ADDRESS",
  "ccEmail": "$env:SMTP_CC_ADDRESS",
  "bccEmail": "$env:SMTP_BCC_ADDRESS",
  "emailSubject": "Email Subject With <<VARIABLE>>",
  "useEmailTemplateFromPayload": false,
  "emailTemplate": "templates/path/to/email_template.html",
  "templateVariables": {
    "VARIABLE": "$env:VARIABLE"
  },
  "smtpDetails": {
    "serverAddress": "$env:SMTP_SERVER_ADDRESS",
    "userName": "$env:SMTP_USERNAME",
    "password": "$env:SMTP_PASSWORD",
    "port": "$env:SMTP_PORT",
    "enableSSL": "$env:SMTP_ENABLE_SSL"
  },
  "leaseLockName": "lock-name",
  "emitEvent": "previous-stage-name-1",
  "preLogTransformSchemaFileName": "schemas/path/to/schema/schema-name.liquid",
  "preLogTransformSchemaType": "liquid|javascript",
  "preLogTransformFormat": "json|xml|csv"
}
PropertySub-PropertyDescription
nameThe name of the stage.
displayNameOptional (but highly recommended). A short (3 or 4 word) "display name" for the stage, used as a "title" of the stage in the Integration Hub Portal service's self-documentation capability.
descriptionOptional (but highly recommended). A brief (10 to 15 word) description of the stage, used as a brief description of the stage's purpose in the Integration Hub Portal service's self-documentation capability. For a more detailed explanation (when needed), use the stage markdown feature.
enabledOptional boolean flag (true or false). Default is true.

Generally set via a DevOps variable. Controls if the stage is deployed enabled or not.
sourceThe source event that the stage subscribes to. See Pub/Sub Model.

Alternatively, sources may be supplied, and an array of one or more source events can be subscribed to.
concurrencyOptional number of concurrent runs permitted for the stage. Default is 10.
fromEmailRequired. The email address that the email message will be sent from, e.g. no-reply@yourdomain.com.
toEmailRequired. A semicolon-separated list of email addresses that the email message will be sent to via the To: field.
ccEmailOptional. A semicolon-separated list of email addresses that the email message will be sent to via the CC: field.
bccEmailOptional. A semicolon-separated list of email addresses that the email message will be sent to via the BCC: field.
emailSubjectRequired. The email subject.

The subject may contain <<VARIABLE>> values which will be replaced via the templateVariables setting below.
useEmailTemplateFromPayloadOptional boolean flag (true or false). Default is false. When true, the stage expects to be provided with a payload containing the email body to be sent. See the Required Payload Format details below.
emailTemplateWhen the useEmailTemplateFromPayload value is false then the emailTemplate must be set, defining a file that contains the email body to be sent, in HTML format. The file may contain <<VARIABLE>> values which will be replaced via the templateVariables setting below.
templateVariablesAn optional object of key/value pairs. Prior to deploying the stage, the email body file will be updated to replace any instances of <<VARIABLE>> in the emailTemplate file with the corresponding value from this object. This allows an email body file to be more easily used across different stages where only minor differences in the email body's content are required.

The key/value pairs can also be used to replace variables in the emailSubject, regardless of if the email body is obtained via a payload or file.
smtpDetails
serverAddressRequired. The hostname or IP address of the SMTP service to use to send the email.
userNameRequired. The SMTP service's username for authentication. Leave blank if authentication is not required.
passwordRequired. The SMTP service's password for authentication. Leave blank if authentication is not required.
portRequired. The SMTP service port to use.
enableSSLRequired boolean flag (true or false). When true, uses SSL (TLS) to connect to the SMTP service.
leaseLockNameOptional. See Lease Locking.
emitEventWhen the email has been sent successfully, the stage will normally terminate. However, under certain circumstances, it may be desirable to continue workflow processing.

The optional emitEvent field allows the payload of a previously run stage to be output as a message from this stage. The stage must have previously been executed in the run history of the overall Integration Hub integration, with the stage's exported payload details being present in the Cloud Event Attributes section.

Pre-Logging Transformation

This stage supports the optional pre-logging transformation feature using the following fields:

  • preLogTransformSchemaFileName
  • preLogTransformSchemaType
  • preLogTransformFormat

See the Pre-Logging Transformation for details.

Required Payload Format

When configured with the useEmailTemplateFromPayload flag set to true, the stage must be triggered with a payload in the following format:

{
  "EmailBody": "<p>HTML email body...</p>",
  "EmailAttachments": [
    {
      "Filename": "report.pdf",
      "ContentType": "application/pdf",
      "ContentData": "<base64 content>"
    }
  ]
}
PropertyDescription
EmailBodyThe email body in HTML format.
EmailAttachmentsAn optional array of attachments to include with the email being sent.
FilenameThe filename to use for the attachment.
ContentTypeThe content type to use for the file attachment.
ContentDataThe Base64 encoded content to be used for the file attachment.

Last updated on