Contact Free trial Login

Sending Emails with the Email Connector

Email Connector can send messages over SMTP and SMTPS.

Configuring the Connector

Separate configuration types are available for listing emails stored in a server:

  • SMTP

  • SMTPS (secured by TLS)

SMTP Configuration Type

Here is an example of an SMTP configuration:

SMTP Configuration
<email:smtp-config name="smtp">
    <email:stmp-connection host="" port="995" user="" password="#netherlands!"/>

Secured Configuration Type

The SMTPS connection type provides a TLS Configuration field in which you can set the TLS context. The configuration enables SSL/TLS encryption and sends encrypted messages over the secured version of the SMTP protocol, SMTPS.

Here is an SMTPS example:

SMTP Configuration with TLS
<email:smtp-config name="smtp">
    <email:stmps-connection host="" port="995" user="" password="#netherlands!"/>
        <tls:context enabledProtocols="TLSv1.2,SSLv3">
            <tls:key-store path="aKeystore" password="password"/>
            <tls:trust-store path="aTruststore.jks" password="changeit"/>

Sending an Email

This example that sends an email:

<email:send config-ref="smtp" subject="IMPORTANT!" fromAddress="">
        <email:to-address value=""/>
        <email:to-address value=""/>
    <email:body contentType="text/html">
        <email:content>"<h1>Hello this is an important message</h1>"</email:content>

In the example above, to-addresses contains the primary recipient addresses of the outgoing email. The fromAddress attribute is the email sender address, and the subject is the email subject.

The body is composed of content text and a contentType that specifies the mime type of the content (for example, text/xml or text/plain). If no body is specified, the content of the message payload is used by default. If that payload is not text, the operation will fail with an EMAIL:SEND error.

Sending Attachments

When sending attachments over SMTP, you need to use DataWeave to handle the attachments.

In this example, a flow reads a JSON file using the File connector, then uses the Email connector to send the contents of the file as an attachment over SMTP:

<flow name="attachment">
  <file:read path="/file.json"/>
  <email:send config-ref="config">
          <email:to-address value=""/>
          <email:content>Sending attachments!</email:content>
          'json-attachment' : payload

As you can see, email:attachments expects a DataWeave expression in which each element is an attachment. For instance, the example above adds a new attachment named json-attachment. Notice that payload is the content of the JSON file that was read by the File connector.