Skip to main content

POP3/IMAP4

Poll email inboxes for incoming messages and trigger integration logic when new emails arrive. WSO2 Integrator supports both the POP3 and IMAP4 protocols through polling-based listeners that check for new messages at a configurable interval.

ProtocolDescriptionDefault port
POP3Downloads messages from the server; messages are typically removed after retrieval995 (SSL)
IMAP4Synchronizes with the server; messages remain on the server after retrieval993 (SSL)

Creating a POP3 listener

note

Creating a POP3 listener requires Ballerina code. Once the listener exists, it appears in the Entry Points sidebar and on the design canvas.

Design canvas showing the POP3 listener node connected to its serviceDesign canvas showing the POP3 listener node connected to its service

Click the service node (or the service name in the sidebar) to open the Email Listener Designer, which lists the event handlers.

Email Listener Designer showing onMessage, onError, and onClose handlersEmail Listener Designer showing onMessage, onError, and onClose handlers

Creating an IMAP4 listener

IMAP4 keeps messages on the server after retrieval and supports multiple mailbox folders.

note

Creating an IMAP4 listener requires Ballerina code. Once the listener exists, it appears in the Entry Points sidebar and on the design canvas.

Design canvas showing the IMAP4 listener node connected to its serviceDesign canvas showing the IMAP4 listener node connected to its service

Click the service node (or the service name in the sidebar) to open the Email Listener Designer, which lists the event handlers.

Email Listener Designer showing onMessage, onError, and onClose handlersEmail Listener Designer showing onMessage, onError, and onClose handlers

Listener configuration

Both email:PopListenerConfiguration and email:ImapListenerConfiguration share the following fields.

FieldTypeDescription
hoststringEmail server hostname
usernamestringEmail account username
passwordstringEmail account password or app-specific token
pollingIntervaldecimalSeconds between polling cycles. Default: 30.
portintServer port. Default: 995 for POP3, 993 for IMAP4.
securityemail:SecurityTransport security mode. Default: SSL. Options: SSL, START_TLS_AUTO, START_TLS_ALWAYS, START_TLS_NEVER.
secureSocketemail:SecureSocket?SSL/TLS configuration for the connection.

Event handler configuration

HandlerTriggerTypical use
onMessageNew email arrives during a polling cycleParse subject and body, route to a downstream system
onErrorA polling cycle failsLog the error, alert on repeated failures
onCloseListener shuts downRelease resources, flush in-flight state

Implementing email processing

Click the onMessage handler row to open its flow designer view, where you can define the integration logic visually.

Flow designer view for the onMessage handlerFlow designer view for the onMessage handler
note

Not all listener configuration options are available through the visual designer. For full control — including SSL/TLS and polling interval settings — use Ballerina code directly.

What's next