How to Flush the Mail Queue in Postfix


May 24, 2023
Written by
Contributor
Opinions expressed by Twilio contributors are their own
Reviewed by
Contributor
Opinions expressed by Twilio contributors are their own

How to Flush the Mail Queue in Postfix

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.

What does queued email mean?

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.

How long does it take for a queued email to send?

The process of queuing emails allows the server to manage and prioritize the delivery of messages based on various factors such as:

  • Server load
  • Network conditions
  • Recipient availability
  • Email deliverability

When an email is queued, it means that it is awaiting its turn for processing and eventual delivery to the recipient's mailbox.

Why is email queued?

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.

How do you send queued emails?

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:

  1. Check your internet connection: Ensure that you have a stable internet connection. Sometimes, connectivity issues can prevent the email from being sent. If you're experiencing connectivity problems, try reconnecting or troubleshooting your internet connection.
  2. Verify the recipient's email address: Double-check the email address of the recipient to ensure it is correct. A small typo or error in the email address can cause the email to queue indefinitely or bounce back.
  3. Check the outgoing email server settings: Verify that your email client or application is correctly configured with the outgoing mail server settings. Ensure that the server address, port number, and authentication credentials (if required) are accurate.
  4. Wait for the queue to clear: If the email was queued due to temporary server issues or high email traffic, you might need to wait for the server to process the queue and send out the emails. In most cases, the server will automatically attempt to deliver the queued emails when it's back to normal operation.
  5. Contact your email service provider: If the email remains queued for an extended period or you suspect there may be an issue with your email service, reach out to your email service provider's support team for assistance. They can help troubleshoot the issue and provide guidance on how to send the queued email.

View queued mail 

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. 

Flush queued mail 

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



Purge queued mail 

To purge the mail queue, we'll use the postsuper -d command. This command has 2 execution options: 

Option 1

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



Option 2

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

 

Increase your deliverability with Twilio SendGrid

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. 


Recommended For You



Most Popular


Send With Confidence

Partner with the email service trusted by developers and marketers for time-savings, scalability, and delivery expertise.