New guide: how to warm up a dedicated IP without hurting your reputation. Read now →
Log in
MigoSMTP
TroubleshootingUpdated 26 Oct 2026

Managing the Mail Queue: Reading Deferred Messages, Flushing, Purging and Preventing Backlogs

How to inspect and manage an MTA mail queue: why messages sit in the queue, reading Postfix queue output, deferral reasons, safe flush and purge, spotting spam floods, scaling workers and monitoring queue depth.

TK
Written by Tomasz Kowalski
Infrastructure and Reliability Engineer
Reviewed by Hannah Mitchell
  • Published11 Jul 2025
  • Read time6 min
  • Length1,227 words
Share this guide

A mail server does not always deliver a message on the first attempt. When the destination is busy, unreachable or unwilling, the server keeps the message in a queue and tries again later. A small, short-lived queue is normal and healthy. A queue that grows without draining is a symptom of a problem: a network fault, a blocked destination, a broken DNS resolver, a misconfigured relay or, in the worst case, a compromised account sending spam. Knowing how to read the queue, interpret the reasons given for deferral and respond without losing legitimate mail is a core operational skill. This guide uses Postfix commands in examples because it is widely deployed, and mentions equivalents for Exim. The concepts apply to any MTA, including managed platforms where you see the same states through a dashboard. See also what a queued email means and 421 deferrals.

NormalMessages wait for retries after temporary (4xx) failures; they are delivered or eventually bounced
ProblemA queue that keeps growing or an age that keeps rising
First stepRead the deferral reason; do not flush or delete blindly
DangerPurging a queue also deletes legitimate customer mail; be precise

How a queue works

In Postfix, messages move between queues: incoming and active for mail being processed, deferred for mail that could not be delivered yet, hold for mail an administrator has paused and corrupt for damaged files. Deferred messages are retried with increasing delay, between a minimum and maximum retry time, until the maximum queue lifetime (by default several days) is reached, after which the server returns a bounce to the sender. Other MTAs use similar ideas with different names. See retries and backoff.

Looking at the queue

postqueue -p            # list the queue (also: mailq)
postqueue -p | tail -1  # summary line: -- 1234 Kbytes in 87 Requests.
postcat -q 4F2A81C3D9   # show one queued message with headers
qshape deferred         # age distribution of deferred mail by recipient domain
postconf mail_version   # confirm the version you are working with

The listing shows the queue ID, size, arrival time, sender and recipients, with the reason a message is deferred in parentheses. For example: (connect to mx.example.net[203.0.113.5]:25: Connection timed out). The command qshape deferred groups messages by domain and age, which quickly reveals whether one destination is responsible for most of the backlog. For Exim the equivalents are exim -bp, exim -bpc for a count and exiqsumm for a summary.

Reading the deferral reason

Reason in the queueLikely causeWhat to do
Connection timed out / refusedRemote server unreachable, firewall or port 25 blockedTest connectivity from the server. See connection timeouts
Host or domain name not foundDNS failure or typo in the domainCheck the resolver and the domain. See MX records
Temporary lookup failureLocal resolver problemFix DNS on the server; restart the resolver
421, 450, 451, 452 with a rate or policy messageRemote throttling or greylistingSlow down; check reputation. See 451 errors and 452 limits
TLS handshake errorsCertificate or protocol mismatchReview TLS settings. See SMTP certificates
Mailbox full (452 4.2.2)Recipient over quotaWait or contact the sender. See mailbox full
Relay access denied / authentication requiredRelay host rejects your serverFix credentials or IP allowlisting. See Postfix relay setup
Blocked using a blocklist or reputationYour IP is listedCheck with the blocklist check. See delisting
Lost connection after DATARemote closed the session, content or size issueReview message size and content. See 421 timeouts

Dealing with a growing queue

  1. Measure. Count messages (postqueue -p | grep -c "^[A-F0-9]") and view the age distribution. Compare with the normal baseline.
  2. Find the dominant reason and destination, using qshape and the reasons in the listing.
  3. Check the basics: DNS resolution, outbound port 25, disk space, load, time synchronisation and the mail log.
  4. Decide whether the mail is legitimate. Look at senders, subjects and volumes. Many messages from one sender to random recipients, or from an unfamiliar local user, indicate a compromised account or script.
  5. Stop the source first if mail is bad: disable the account, change credentials, block the script, then deal with the queue. See account compromise response.
  6. Fix the cause of deferral for legitimate mail, then let normal retries run or flush.
  7. Watch it drain. A healthy queue shrinks steadily; sudden re-growth means the cause remains.

Flush, hold, requeue and purge

CommandEffectUse with care
postqueue -fAttempt immediate delivery of all deferred mailCan hammer destinations that are throttling you; flush only after fixing the cause
postqueue -s example.netFlush mail for one domainSafer, targeted
postsuper -h IDHold a message so it is not deliveredGood for suspicious mail pending review
postsuper -H IDRelease a held messageReview first
postsuper -r ALL deferredRequeue deferred messages, re-evaluating routingUseful after changing transport maps or DNS
postsuper -d IDDelete one messageIrreversible
postsuper -d ALL deferredDelete all deferred mailAlmost never correct; deletes customer mail without bounce notices

To delete only the spam, filter by sender or recipient rather than wiping the queue, and keep a copy of what you remove if you may need to investigate. Remember that deleting a message gives the original sender no notice. If legitimate mail must be abandoned, it is kinder to let it expire naturally with a bounce, or to notify the sender. For a hold-and-review workflow, move suspect messages to hold, inspect samples with postcat, then delete the confirmed spam by ID.

Worked example

Suppose the queue jumps from about 200 messages to 12,000 within an hour. The age listing shows most of the mail is under sixty minutes old and addressed to hundreds of different domains, and the senders are all one local user, which points to a compromised account or script. You disable the account, hold the messages from that sender, inspect a few with the queue content command, confirm they are spam and delete them by ID. The remaining legitimate mail is flushed. Afterwards you add a per-user rate limit and check the outbound IP against blocklists, since the burst may already have caused listings. Had the age listing instead shown old mail for a single domain, the cause would be that destination, and the response a connectivity test, not a purge.

Prevent backlogs

  • Rate-limit by sender. Limit messages per user per hour so that a compromised account cannot flood the queue.
  • Authenticate submissions and never run an open relay. See IP allowlists.
  • Use sensible concurrency per destination so that you do not trigger remote throttling.
  • Separate queues or transports for transactional and bulk mail, so a bulk backlog does not delay password resets. See separate streams.
  • Set a reasonable maximum queue lifetime for your business; a short lifetime for time-sensitive mail avoids delivering stale messages days later.
  • Keep disk space and inodes available. A full disk stops the queue.
  • Monitor DNS and outbound connectivity as part of mail health.

Monitoring

Alert on queue size, oldest message age, the number of deferred messages per destination and the delivery rate. A simple check on the queue count with warning and critical thresholds catches most incidents, and an age-based alert catches slow leaks that a count would miss. Graph the values so you can see patterns, such as a nightly batch that raises the count briefly. Log deferral reasons in a structured way so that dashboards show which reasons dominate. See delivery monitoring and the incident runbook.

A queue is a buffer that tells you about the health of everything around it. Read it before you touch it, find the reason that dominates, fix that cause and let the retries do the work.

Skip the queue management Use a managed relay with built-in retries and delivery logs.

Explore the SMTP relay

References and further reading

Frequently asked questions

Why are my emails stuck in the queue?

They are deferred after a temporary failure such as a timeout, DNS problem, throttling or a blocklist. Read the reason in the queue listing.

Is it safe to flush the queue?

Only after fixing the cause. Flushing during throttling or a block can make things worse; target specific domains where possible.

How do I delete only spam from the queue?

Filter by sender, recipient or content and delete by queue ID, rather than purging the whole queue.

How long do queued messages stay?

Until delivered or until the maximum queue lifetime is reached, after which a bounce is returned. Postfix defaults to several days.

What is the first sign of a compromised account?

A sudden queue of messages from one local user to many unrelated recipients.

Topics#mail queue#postfix#deferred#mta#monitoring
Was this guide helpful?Your answer helps us improve our documentation.

Start sending in minutes.

Create an account, add your domain and send your first email.

Get started Talk to sales