Skip to main content
The Email Gateway is a FlowX.AI microservice that handles email communication workflows. It is available as a Docker image and requires specific infrastructure components to function properly.

Dependencies

Before setting up the Email Gateway, ensure you have the following dependencies in place:
  • PostgreSQL database for storing email gateway data
  • MongoDB connection to the app-runtime database for runtime data access
  • Kafka for event-driven communication with other FlowX.AI services
  • Redis for caching
  • Keycloak (or compatible OAuth2 provider) for authentication and authorization
The Email Gateway does not require an ingress configuration as it operates as an internal service communicating via Kafka.

Infrastructure prerequisites


Configuration

Authorization configuration

The Email Gateway validates incoming tokens with the JWT public key mechanism and authenticates to other FlowX services with a dedicated service account (the mainIdentity client registration) in the service-accounts realm:
Upgrading from 5.1.x? Remove the legacy opaque-token env vars: SECURITY_OAUTH2_REALM, SECURITY_OAUTH2_CLIENT_CLIENTID, SECURITY_OAUTH2_CLIENT_CLIENTSECRET, and SECURITY_OAUTH2_SERVICEACCOUNT_ADMIN_*. These belong to the removed introspection model and prevent the service from starting on 5.9.x. See the authentication and IAM migration guide for the full list.

PostgreSQL configuration

The Email Gateway uses its own dedicated PostgreSQL database for storing email-related data.
Ensure the email_gateway database is created before deploying the service. The Email Gateway will manage its own schema migrations.

MongoDB configuration (app-runtime)

The Email Gateway connects to the shared app-runtime MongoDB database for accessing runtime data.
The retryWrites=false parameter is required for compatibility with MongoDB replica set configurations that include arbiters.

Redis configuration

Email Gateway uses Redis for caching. Configure Redis connection using the standard Redis environment variables. Quick reference:
Both SPRING_DATA_REDIS_* and SPRING_REDIS_* variable prefixes are supported. The SPRING_DATA_REDIS_* prefix is the modern Spring Boot standard and is recommended for new deployments.
For advanced Redis deployment modes (Sentinel, Cluster) and SSL/TLS setup, see the Redis Configuration guide. Note that Sentinel and Cluster modes are only supported by the Events Gateway service.

Kafka configuration

Core Kafka settings

OAuth authentication (when using SASL_PLAINTEXT)

When using the kafka-auth profile, the security protocol will automatically be set to SASL_PLAINTEXT and the SASL mechanism will be set to OAUTHBEARER.

Topic naming configuration

IMAP configuration

Configure the Email Gatewayโ€™s IMAP polling behavior for inbound email processing:

Microsoft Graph configuration

The client cache TTL controls how long authenticated MS Graph client instances are kept in memory before being refreshed. Increase this value in stable environments to reduce token refresh overhead.

Master election configuration

The Email Gateway uses a master election mechanism to coordinate work across multiple replicas:

Rebalancing configuration

Configure how email accounts are distributed across service instances:

Kafka topics

The Email Gateway publishes to the following Kafka topics:

Logging configuration

Control logging levels for different components:

Secrets management

The Email Gateway requires several secrets to be configured. These should be stored securely and referenced via Kubernetes secrets or a secrets management solution.

Deployment

Helm values example

Below is an example Helm values configuration for deploying the Email Gateway:

Network policies

The Email Gateway requires network access to the following services:

Monitoring

The Email Gateway exposes Prometheus metrics for monitoring. Enable scraping by setting the pod label:

Health endpoints


Troubleshooting

Common issues

Symptoms: Service fails to start with database connection errors.Solutions:
  1. Verify the email_gateway database exists in PostgreSQL
  2. Check that the database user has appropriate permissions
  3. Ensure network connectivity between the pod and PostgreSQL service
  4. Verify the JDBC URL format is correct
Symptoms: Errors accessing app-runtime data.Solutions:
  1. Verify MongoDB replica set is healthy
  2. Check that retryWrites=false is set in the connection URI
  3. Ensure the MongoDB user has read access to the app-runtime database
  4. Verify network policies allow MongoDB traffic
Symptoms: Kafka consumer/producer fails to connect.Solutions:
  1. Verify OAuth token endpoint is accessible
  2. Check Kafka OAuth client credentials
  3. Ensure the kafka-authz realm exists in Keycloak
  4. Verify network connectivity to both Kafka and Keycloak
Symptoms: 401/403 errors when calling other FlowX services.Solutions:
  1. Verify the Keycloak service account is properly configured
  2. Check that client secrets match between configuration and Keycloak
  3. Ensure the service account has required roles assigned

Email Trigger

Configure IMAP connections to trigger processes from incoming emails

Email Sender

Configure SMTP connections to send emails from processes

Microsoft Outlook

Connect to Outlook via MS Graph API for reading and sending emails

Redis Configuration

Complete Redis setup including Sentinel and Cluster modes

Kafka Authentication

Configure Kafka security and authentication

IAM Configuration

Identity and access management setup
Last modified on June 24, 2026