READ ME FIRST
This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.
This article will show you how to manage and clear mail queues using the built-in functionality of Postifx.
CloudTech Can Help!
(mt) Media Temple offers email queue management through CloudTech, our premium services division. To learn more, please click here.
Examining The Queue
- You can view the current status of the mail queue by running the command 'postqueue -p':
bash-4.1# postqueue -p -Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- 7DA67C27B8* 3499 Thu Apr 11 18:35:37 MAILER-DAEMON firstname.lastname@example.org AB5C2C27B9* 356 Thu Apr 11 18:36:00 email@example.com firstname.lastname@example.org
- You can use the 'postcat' command to view the contents of messages in the queue. Using the example above, we could view the second message in the queue by running 'postcat' with the 'queue id' of the message in question. In this example, we are using the 'q' flag, which shows the whole message. However, there are various flags for showing different aspects of the message, such as just headers, or body. For a full listing of 'postcat' flags, type 'man postcat'.
bash-4.1# postcat -q AB5C2C27B9 *** ENVELOPE RECORDS active/28BABC27B9 *** message_size: 2428 235 1 0 2428 (output truncated)
Flushing The Queue
- You can 'flush' the queue by issuing the following command:
bash-4.1# postfix flush
This DOES NOT clear the mail queue entirely. Instead, it will attempt to deliver every message in the deferred mail queue. Normally, attempts to deliver delayed mail happen at regular intervals, the interval doubling after each failed attempt.
Flushing undeliverable mail frequently will result in poor delivery performance of all other mail.
Deleting The Queue
- To delete the entire mail queue, run the following command:
bash-4.1# postsuper -d ALL
The 'postsuper' command performs lots of other important functions. For a full listing, type 'man postsuper'.
This article will show you how to use qmHandle to clear out mail queues on servers running QMail.
- If you're running an older DV server, it may be necessary to install qmHandle manually before continuing.
- It is first recommended to shut down qmail using to prevent possible corruption of the mail queue:
service qmail stop
- qmHandle can show it's own options when run without a flag:
./qmHandle qmHandle v1.3.2 Copyright 1998-2003 Michele Beltrame Available parameters: -a : try to send queued messages now (qmail must be running) -l : list message queues -L : list local message queue -R : list remote message queue -s : show some statistics -mN : display message number N -dN : delete message number N -Stext : delete all messages that have/contain text as Subject -D : delete all messages in the queue (local and remote) -V : print program version Additional (optional) parameters: -c : display colored output -N : list message numbers only (to be used either with -l, -L or -R) You can view/delete multiple message i.e. -d123 -v456 -d567
- Use the -s flag to see some basic statistics:
qmHandle -s Messages in local queue: 0 Messages in remote queue: 10
- Use the -l flag to see stats about each message in the queue. This can get very long, so you may wish to use the -N to see just the message numbers:
qmHandle -l 10601551 (0, R) Return-path: From: MAILER-DAEMON@domain.com To: email@example.com Subject: failure notice Date: 30 Mar 2006 18:12:36 -0800 Size: 1706 bytes ...
- Use the -m flag to view the contents of a particular message. Get the message number from the queue:
qmHandle -m10600494 MESSAGE NUMBER 10600494 -------------- Received: (qmail 15035 invoked for bounce); 5 Apr 2006 08:21:30 -0700 Date: 5 Apr 2006 08:21:30 -0700 From: MAILER-DAEMON@domain.com To: firstname.lastname@example.org Subject: failure notice Hi. This is the qmail-send program
- Use the -D flag to delete all messages in both the incoming and outgoing queues. Please be careful, as this is not undoable!
qmHandle -D Calling system script to terminate qmail... Deleting message: 0/10601551 [ OK ] Deleting message: 1/10600494 Deleting message: 15/10601566 Deleting message: 16/10601567 Deleting message: 18/10601569 Deleting message: 20/10601571 Deleting message: 22/10601550 Deleting message: 6/10601557 Deleting message: 8/10601582 Deleting message: 9/10601583 Restarting qmail... Starting qmail: [ OK ] done (hopefully).