Send With Confidence
Partner with the email service trusted by developers and marketers for time-savings, scalability, and delivery expertise.
Time to read: 6 minutes
Postfix is a popular open-source mail transfer agent (MTA) that routes and delivers email. Occasionally, as part of the administration of this service, users will view, flush, and purge Postfix mail queues. These actions facilitate the manipulation of email delivery, enabling message reprioritization and/or cancellation. Such actions often occur when the recipient's host defers or rejects the message.
When an email is sent via Postfix, it doesn't immediately get delivered to the recipient. Instead, it first enters the queue. There are several reasons for this staging process, including:
The Postfix system typically manages multiple queues for different purposes:
Administrators can interact with these queues using various Postfix commands to view the status of emails, flush the queue to force processing, or purge emails to remove them from the queue entirely.
A queued email refers to an email message that has been placed in a queue or a waiting line for delivery. When an email is sent, it typically goes through several stages before reaching its intended recipient. One of these stages involves being placed in a queue for processing and delivery by the email server.
Here's what happens when an email is queued:
Processing: The email server processes the email, preparing it for delivery. This can involve several steps, including checking for spam, applying security filters, and possibly sorting it based on priority or other criteria set by the server's rules.
Delivery Wait: The queued email waits its turn to be sent out. This waiting period can be influenced by several factors such as server load, network conditions, or prioritization rules that may delay certain emails.
Delivery Attempt: The email server attempts to deliver the queued email to the recipient’s server. If successful, the email moves from the queue to the recipient's inbox. If not, it may be queued again for a later retry, especially if the issue is temporary (like a recipient server being down).
The queuing system helps manage and optimize the flow of outgoing emails, ensuring that they are delivered in an orderly and efficient manner. It also provides a mechanism for handling errors and retries without losing any messages.
The process of queuing emails allows the server to manage and prioritize the delivery of messages based on various factors such as:
When an email is queued, it means that it is awaiting its turn for processing and eventual delivery to the recipient's mailbox.
Sometimes, a message will send almost immediately. However, it can enter a queue for various reasons.
For example, if the email server is experiencing high traffic or temporary connectivity issues, emails may accumulate in the queue until the server can process them. Additionally, certain email services or servers may have specific limitations or restrictions that could cause emails to be temporarily queued before being delivered.
Once the queued email reaches the front of the queue and the necessary processing conditions are met, it will be delivered to the recipient's email address.
If an email gets queued, it means that it hasn't been sent yet due to certain circumstances. This isn't a problem (yet), so you don't need to take any immediate action. However, if you need to send an urgent message to your recipients or find your queue hasn't cleared in some time, here are some steps you can take to address the situation:
In order to accomplish multiple queue operations, such as flushing or purging, we must first see what email is in the queue. To accomplish this, we'll use the postqueue -p command.
mailhost01:~ user01$ postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
75E95197CF2E* 315 Wed Jul 15 16:27:07 sender@test.com
recipient@test.com
87717197CE88* 315 Wed Jul 15 16:26:39 sender@test.com
recipient@test.com
In the above example, each queue entry shows the queue file ID, message size, arrival time, sender, and the recipients that still need to be delivered. The “*” or “!” characters at the end of the queue ID string represent the message’s queue status: active or hold.
To flush the mail queue, we'll use the postqueue -f command. This command will attempt to redeliver all queued mail. However, use the command sparingly, as multiple flushes will impact the overall performance of your mail server.
mailhost01:~ user01$ postqueue -f
To purge the mail queue, we'll use the postsuper -d command. This command has 2 execution options:
To purge a single email from the queue, use the postsuper -d [message id] command.
mailhost01:~ user01$ postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
75E95197CF2E* 315 Wed Jul 15 16:27:07 sender@test.com
recipient@test.com
87717197CE88* 315 Wed Jul 15 16:26:39 sender@test.com
recipient@test.com
mailhost01:~ user01$ sudo postsuper -d 75E95197CF2E
postsuper: 75E95197CF2E: removed
postsuper: Deleted: 1 message
To purge all email from the queue, use the postsuper -d ALL command.
mailhost01:~ user01$ postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
75E95197CF2E* 315 Wed Jul 15 16:27:07 sender@test.com
recipient@test.com
87717197CE88* 315 Wed Jul 15 16:26:39 sender@test.com
recipient@test.com
mailhost01:~ user01$ sudo postsuper -d ALL
postsuper: Deleted: 2 message
The need to manipulate mail queues is often the result of recipient hosts deferring or rejecting your messages. These deferrals or rejections will impact your overall email deliverability, which, in return, has a negative impact on your ability to communicate with your recipients.
To read more about improving your email deliverability, review Twilio SendGrid’s annually published Email Deliverability Guide. And when you're ready to increase your deliverability, reach out to our Expert Services to get started for free.
Partner with the email service trusted by developers and marketers for time-savings, scalability, and delivery expertise.