Postfix has long been considered one of the best MTA available. Initially written by Wietse Venema Zweitze and released under the IBM Public License , Postfix can boast a solidity and an ease of interaction found in other demons SMTP mail.

The decision to deploy its capabilities of different demons - each of which performs a specific function - and the award for minimum performance for each group, ensures that any bugs or exploits can not compromise the entire MTA. A single process must be run with root privileges, all other rights are minimal and often just a configuration file.

This distribution of tasks is also reflected in the availability of several tools specifically designed to perform functions of monitoring and administration of processes generated by Postfix. Some of these tools are part of Postfix, while others are accessory items - often developed by third parties - that interact with it at various levels.

The monitoring of the mail queues, for example, can be done with the `mailq`:

# mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
6CC39230001* 1389 Wed Jun 25 01:17:51 5tanya.wuhc@msa.hinet.net
test@dominio.it

I refer the usual newbie `man` mailq for basic information on how the program works. What follows is an example of how you can best make use `mailq` to remove frozen mail from local spool:

# exim -Mg `mailq | grep frozen | awk '{ print $3 }'`

The normal use of `mailq` may be thwarted by the presence of very massive mail queues. In these cases it is good to deploy the script `` qshape to get a clear picture of what has led to the accumulation of messages and when it happened:

$ qshape -s deferred | head
T 5 10 20 40 80 160 320 640 1280 1280+
TOTAL 1250 0 1 2 4 5 22 34 118 242 822
spammer123.com 462 0 1 0 1 1 3 7 15 53 381
zzfinder.com 64 0 0 0 0 0 1 0 0 4 59
socket4you.biz 53 0 0 0 0 0 0 0 0 0 53
junglex.com 36 0 0 0 0 0 1 3 7 15 10
myemessage.com 36 0 0 0 0 0 0 0 0 0 36
stock911.us 35 0 0 0 0 0 0 0 0 0 35
linuxassistance.it 33 0 0 0 0 0 0 0 0 0 33
agliardi.biz 29 0 0 0 0 0 0 0 0 3 26

Here we see that there are 1250 messages in the queue for which was made ​​at least one attempt at delivery (deferred), of which 462 are routed to domain spammer123.com. Of emails sent to this domain 1 is in the queue for a period of time between 5 and 10 minutes, while 381 are waiting for more than 1280 minutes.

The following command is used instead to display statistics related to the number of recipients of mail in the queue "active" Postfix:

qshape active | less

In this way we can identify at any time any "bottlenecks", ie abnormal mailings that accumulate in the Postfix queue significantly degrade performance. Once identified similar processes, we can eradicate them using the command `` postsuper:

postsuper [-psv] [-c directory_file_conf] [-d][-h][-H][-r] [id_coda] [directory_coda]

To eliminate, for example, with the message queue ID 6CC39230001 (ie the one shown in the example above) is sufficient to run the command:

# postsuper -d 6CC39230001

If, instead, at your own risk, you want to completely empty the mail queue, you can always use the following command:

# postsuper -d ALL deferred

But if you ever lose email because of the use of this second example, do not you take it with me.