Overview
Stalwart MTA provides a flexible framework for managing outbound email delivery. Messages sent to both local and external domains are processed through a strategy-driven architecture that allows precise control over how, when, and where each message is delivered. Delivery strategies are evaluated dynamically for each recipient, adapting behaviour to the message context, such as the recipient domain, the sender's identity, message type, or assigned priority.
Strategies
Delivery strategies define the behaviour and policies used when Stalwart MTA delivers email messages, whether to local recipients or remote systems. Strategies allow dynamic delivery logic driven by runtime conditions: expressions are evaluated for each recipient and message, so routing, scheduling, connection parameters, and transport security can all adapt to the context of each delivery.
Queues
Queues are the holding area for outbound messages. When a message arrives, it is placed in a queue until it can be delivered to its final destination. Stalwart supports an unlimited number of virtual queues, so administrators can create and configure multiple queues with different settings and behaviours. This allows separate queues for different classes of traffic, each processed with its own concurrency and retry characteristics.
Scheduling
A scheduling strategy defines the policies and behaviour that govern how outbound message deliveries are managed over time. Scheduling strategies control which virtual queue a message uses, how often delivery is retried after a failure, when delayed delivery-status notifications are generated, and when undeliverable messages are expired and bounced to the sender.
Routing
Message routing determines the final destination host for a message. When a message is processed for delivery, the selected routing strategy defines whether it should be delivered locally, resolved through DNS, or sent through an intermediate relay.
Connection
A connection strategy defines how Stalwart MTA establishes SMTP connections to remote servers during message delivery. While routing strategies determine where messages are delivered, connection strategies control how those connections are made. A connection strategy specifies parameters such as the source IP address to bind to, the hostname to advertise in the EHLO command, and timeout values for each stage of the SMTP session. This level of control is useful in multi-homed systems, outbound IP rotation setups, or when complying with specific policy or network constraints.
TLS
Stalwart uses TLS to secure message transmission over the internet. TLS (Transport Layer Security) provides encryption, authentication, and integrity for data in transit, preventing unauthorised access and tampering. Stalwart's TLS implementation is built on rustls, a high-performance TLS library.
Rate limits
Rate limiting controls the flow of connections and messages by restricting the number of operations allowed over a specific time period. In Stalwart, rate limiting ensures that email traffic is managed efficiently, preventing resource overuse and protecting the server from abuse such as spam or denial-of-service attacks.
Quotas
Quotas set limits on the message queue to control its size and total number of messages. Stalwart supports dynamic quotas, which can limit the total size and number of messages waiting to be delivered based on multiple variables. When a queue quota is exceeded, messages are temporarily rejected with a 4xx SMTP code, protecting the server from becoming overwhelmed while ensuring important messages continue to be delivered.