mail egress connector

Mail Egress Connector

Version: 17.07

Supported Since: 17.01

What is Mail Egress Connector?

The Mail Egress Connector can be used to send emails using UltraESB-X via a mail server.

In order to use the Mail Egress Connector, you must first select the Mail Connector dependency from the connector list when you are creating an empty Ultra project. If you have already created a project, you can add the Mail Connector dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Connectors list, select the Mail Connector dependency.
mail egress connector 1

Out Ports

Response Processor

The message will be sent to this out port if the Complete Flow property is disabled and the message has been sent to the email address successfully

On Exception

The message will be sent to this out port if the Egress Connector failed to process the message due to some reason

Side Ports

Connector Operation

This port is used to connect operational elements to the Egress Connector. By default, user does not have to connect any operational element and the default connector operation will be used.

Parameters

* marked fields are mandatory

Protocol *

Basic

Protocol to be used for accessing the mail server. SMTP (smtp) is recommended.

Host *

Basic

Hostname (or IP address) of the mail server

Port *

Basic

Service port on the mail server (usually dependent on the protocol)

User *

Basic

Username for authenticating to the mail server

Password *

Basic

Password for authenticating to the mail server

Other Settings

Basic

Map of additional transport-level properties for mail server access, such as standard JavaMail properties (e.g. enabling SSL as in the above example)

Weight

Advanced

Weight for the Egress Connector if this Egress Connector is under a weighted Egress Load Balancer

Complete Flow

Advanced

If true, the integration flow will be completed once the message has been sent to the email address. If false, the original message sent to the email address will be emitted to the Response Processor out port to continue the flow

From

Composition

From address for the outbound email

Reply-To

Composition

Reply-To address to be included in the outbound email

To

Composition

A comma-separated list of To addresses for the outbound email

CC

Composition

A comma-separated list of CC addresses for the outbound email

BCC

Composition

A comma-separated list of BCC addresses for the outbound email

Subject

Composition

Subject of the outbound email

Priority

Composition

Priority of the outbound email (may be email provider specific)

Sample Use case

A minimal configuration for the Mail Egress Connector consists of the following:

  • Protocol

  • Host

  • Port

  • User

  • Password

In addition, at least one of the To, CC or BCC fields may need to be specified as the email recipient. If none is specified, the destination address of the message will be used as the To address of the outbound email. Some mail server implementations may also require a suitable From address for the outbound email.

If the mail service is accessible only over SSL (as is the case with mail providers like Gmail or Yahoo), an Other Settings Map containing mail.<protocol>.starttls.enable set to true will also have to be specified. The Other Settings Map can also be useful for specifying other custom transport-related parameters, such as standard JavaMail parameters.

In order to trigger the mail sending flow, let’s start with a Timer Ingress Connector as the ingress connector for the flow (which will generate only a single "tick", Polling Repeat Count having been set to 0, hence sending out only one test email):

timer sceduling
Figure 1. Timer Ingress Connector Configuration

Since the inbound message from the Timer Task Listener has no payload, let’s add a String Payload Setter to populate the message with a test payload string (which will be made available as the body of the email):

payload setter basic
Figure 2. String payload Setter Configuration

If the payload is of text/html content type, a multipart email would be generated appropriately, but otherwise a plaintext email would be generated with the raw message payload as the email body.

If attachments are available in the UltraESB-X message received by the Mail Egress Connector, they would be attached to the outbound email. Add a File Attacher element to attach a file from a known location to the message:

file attacher basic
Figure 3. File Attacher Configuration

Also, create a file /tmp/test.txt with some sample text, to be picked by the File Attacher.

Finally, let’s add a Mail Egress Connector for sending out the enriched message as an email, with the following configurations:

mail egress connector basic
Figure 4. Mail Egress Connector Basic Tab Configuration

For Other Settings add a String map as shown below

other setting map
Figure 5. Other Settings Map Configuration
mail egress connector composition
Figure 6. Mail Egress Connector Composition Tab Configuration

(Replace the email account user, password and the From, Reply-To and destination email addresses as per your choice.)

The final flow would resemble the following:

mail egress connector 2

For this exercise, in order to see the actual email sending in action, let’s increase the log level of the mail transport by updating src/test/resources/log4j2.xml:

log4j2.xml (src/test/resources/)

<Configuration ...>
    ...
    <Loggers>
        ...
        <AsyncLogger name="org.adroitlogic.x.transport.mail" level="TRACE"/>

Now, after creating a run configuration and running the project, you will be able to see an email being composed and sent via the configured email account:

2017-01-24T14:22:00,791 [127.0.1.1-janaka-ENVY] [pool-2-thread-1] [mail-sample-17.01-beta6] [000000D000] DEBUG MailTransportSender Composing outbound email using message cf801ad2-4e57-ce6c-0000-000000000001
2017-01-24T14:22:00,810 [127.0.1.1-janaka-ENVY] [pool-2-thread-1] [mail-sample-17.01-beta6] [000000T000] TRACE MailTransportSender From aliceandbob2016@gmail.com
2017-01-24T14:22:00,811 [127.0.1.1-janaka-ENVY] [pool-2-thread-1] [mail-sample-17.01-beta6] [000000T000] TRACE MailTransportSender Reply-To janakaud@gmail.com
2017-01-24T14:22:00,812 [127.0.1.1-janaka-ENVY] [pool-2-thread-1] [mail-sample-17.01-beta6] [000000T000] TRACE MailTransportSender To [aliceandbob2016@gmail.com]
2017-01-24T14:22:00,813 [127.0.1.1-janaka-ENVY] [pool-2-thread-1] [mail-sample-17.01-beta6] [000000T000] TRACE MailTransportSender BCC [janakaud@gmail.com]
2017-01-24T14:22:00,813 [127.0.1.1-janaka-ENVY] [pool-2-thread-1] [mail-sample-17.01-beta6] [000000T000] TRACE MailTransportSender Subject Test Subject
2017-01-24T14:22:00,813 [127.0.1.1-janaka-ENVY] [pool-2-thread-1] [mail-sample-17.01-beta6] [000000T000] TRACE MailTransportSender Adding attachment test.txt
2017-01-24T14:22:00,816 [127.0.1.1-janaka-ENVY] [pool-2-thread-1] [mail-sample-17.01-beta6] [000000T000] TRACE MailTransportSender Adding payload as plaintext
2017-01-24T14:22:00,816 [127.0.1.1-janaka-ENVY] [pool-2-thread-1] [mail-sample-17.01-beta6] [000000D000] DEBUG MailTransportSender Composed outbound email using message cf801ad2-4e57-ce6c-0000-000000000001
2017-01-24T14:22:00,816 [127.0.1.1-janaka-ENVY] [pool-2-thread-1] [mail-sample-17.01-beta6] [000000T000] TRACE MailTransportSender Sending email for message cf801ad2-4e57-ce6c-0000-000000000001 to [aliceandbob2016@gmail.com] BCC [janakaud@gmail.com]
...
DEBUG SMTP: connected to host "smtp.gmail.com", port: 25
...
DEBUG SMTP: AUTH LOGIN succeeded
...
MAIL FROM:<aliceandbob2016@gmail.com>
250 2.1.0 OK 63sm25307141wmg.2 - gsmtp
RCPT TO:<aliceandbob2016@gmail.com>
...
Subject: Test Subject
MIME-Version: 1.0
Content-Type: multipart/mixed;
	boundary="----=_Part_0_1635565058.1485247920799"
...
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

test payload
...
Content-Type: text/plain; charset=us-ascii; name=test.txt
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=test.txt

test attachment
...
250 2.0.0 OK 1485247935 63sm25307141wmg.2 - gsmtp
DEBUG SMTP: message successfully delivered to mail server
...
2017-01-24T14:22:11,139 [127.0.1.1-janaka-ENVY] [pool-2-thread-1] [mail-sample-17.01-beta6] [000000D000] DEBUG MailTransportSender Successfully sent email for message cf801ad2-4e57-ce6c-0000-000000000001 to [aliceandbob2016@gmail.com] BCC [janakaud@gmail.com]

Now check the email accounts under the To and BCC fields, to verify that the email has been sent out correctly. The email will contain the Test Subject subject, with a plaintext email body test payload and a test.txt attachment containing the text from /tmp/test.txt. If you attempt to reply to the email, the recipient of the composed email would be the address included in the Reply-To field, rather than the original sender (From address).

In this topic
In this topic
Contact Us