Skip to content

Queue management

When a message has not arrived, the outbound queue is where the administrator finds out why. It holds every message that is waiting to be delivered, with the state of each recipient, and it is also where a message is retried once a fault is fixed, or cancelled when it should not be delivered at all.

The server creates queued messages itself as mail flows, and an administrator cannot create them. They are QueuedMessage objects, managed through the WebUI, the CLI or the JMAP API, which allow them to be listed, viewed, updated to reschedule or cancel recipients, and deleted.

Each message in the queue is a QueuedMessage (found in the WebUI under Management › Emails › Queued). The object shows the envelope sender of the message, its size and its priority. For each recipient, it also shows the delivery state:

  • The virtual queue the recipient is in
  • The delivery status and the number of attempts made
  • The time of the next attempt, of the next delay notification and of the expiry
  • The error returned by the last attempt

Messages can be searched by text, by recipient, by queue, by sender or by due time. The following commands list the queued messages for a recipient and then show one of them:

Terminal window
stalwart-cli query QueuedMessage --where [email protected]
stalwart-cli get QueuedMessage <id>

After a problem on the remote server has been fixed, there is no need to wait for the next scheduled attempt: the message can be retried at once. Setting nextRetry to a time reschedules every recipient of the message that has not failed permanently. The following command sets the next attempt to a given time, which in this case is the present moment:

Terminal window
stalwart-cli update QueuedMessage <id> --field nextRetry=2026-10-15T12:00:00Z

To reschedule a single recipient instead of the whole message, use the field recipients/<address>/retryDue in place of nextRetry.

A recipient that has failed permanently is not affected by nextRetry. Retrying it takes two steps. First, set its status back to scheduled with --field 'recipients/<address>/status={"@type":"Scheduled"}'. Then reschedule it in a separate update.

Delivery can be cancelled for one recipient or for the whole message. Removing a recipient from the message with --field 'recipients/<address>=null' cancels its delivery, and the cancellation is recorded as Delivery canceled. Once no recipient is left to deliver, the message itself is removed. To remove the message with all its recipients at once, delete the QueuedMessage:

Terminal window
stalwart-cli delete QueuedMessage --ids <id>

Sometimes deliveries must stop for a while without refusing new mail. The PauseMtaQueue and ResumeMtaQueue actions stop and restart the delivery of queued messages, and they act on every node of the cluster. While the queue is paused, Stalwart still accepts messages and queues them, but it delivers nothing until the queue is resumed. Pausing is useful during maintenance of a relay or of the network. It is also useful to examine the queue while no delivery is changing it:

Terminal window
stalwart-cli create Action/PauseMtaQueue
stalwart-cli create Action/ResumeMtaQueue

The paused state is kept in the memory of each node and is not stored. A node that starts while the rest of the cluster is paused, whether it was restarted or has just joined, therefore comes up with its queue running and begins delivering the messages that are due, while the other nodes remain paused. After restarting a node during maintenance, send PauseMtaQueue again to stop it as well. Deliveries can begin within seconds of startup, so messages that were already due may leave from that node before the action arrives.