Postqm
Examples
Below are some invocation examples. They are meant to wet your appetite and show you how to inspect and take action on the entries in your mail queue.
Top
The top subcommand lets you see common characteristics of messages using large amounts of resources.
To see the top subjects of queued messages you would call:
% postqm top 2 Newsletter 419 2 Your notifications from some site 8 Delivery Status Notification (Failure) 20 You Have 1 Unread Message 153 Undelivered Mail Returned to Sender ----- ------- COUNT SUBJECT
To see the top recipients of queued messages you would call:
% postqm top recipient 2 anotherrecipient@oursite.tld 2 anotheruser@oursite.tld 4 someuser@oursite.tld 19 mailinglistlover@oursite.tld 22 newsletter@emailads.tld 47 noreply@bulkmailsite.tld ----- --------- COUNT RECIPIENT
If you are more concerned with the amount of space consumed by queued messages per sender you would call:
% postqm top sender size 1924 test@test.tld 3071 someuser@business.tld 3668 service@noreply.emailservice.tld 5263 bounce_20546@clickspam.tld 7732 newsletter@emailads.tld 8331 someuser@oursite.tld 9501 ndn@spampromotion.tld 15493 ''@mta.oursite.tld 28549 mailer-daemon 68798 bounce@bulkmailsite.tld 162617 heavyuser@oursite.tld --------- ------ SUM(SIZE) SENDER
And if instead you'd like to see whose messages your servers aren't able to deliver you'd call:
% postqm top recipient qage average 0 stillmoreusers@oursite.tld 0 yetanotheruser@oursite.tld 0 msgid@workstation.oursite.tld 0 anotheruser@oursite.tld 0 someuser@oursite.tld 0 someuser@customer.tld 3 promotion@emailservice.tld 3 anotherbrokenuser@oursite.tld 3 noreply@communitysite.tld 4 brokenmailbox@oursite.tld ------------- --------- AVERAGE(QAGE) RECIPIENT
Ls
The ls subcommand provides a listing similar
to postqueue -p
with header fields listed
if requested.
To see messages from mailer-daemon aged one day or more including the date field you would call:
%postqm -i sender eq mailer-daemon -i qage gt 0 ls date 58CD5281979 18919 1 2009-05-01 mailer-daemon lostside@sunny.tld date: ['Fri, 1 May 2009 23:26:13 +0200 (CEST)'] 64B972818A1 17289 1 2009-05-01 mailer-daemon 6136if2bcad7165f4@bounced.tld date: ['Fri, 1 May 2009 21:16:45 +0200 (CEST)'] BF10228193B 18886 1 2009-05-01 mailer-daemon lostrasins@xn.5h.tld date: ['Fri, 1 May 2009 23:24:14 +0200 (CEST)'] 82044281853 4829 1 2009-05-01 mailer-daemon someuser@windmills.tld date: ['Fri, 1 May 2009 21:54:28 +0200 (CEST)'] 207B4281BAA 24547 1 2009-05-01 mailer-daemon a85d8bi1511479665c@bounced.tld date: ['Fri, 1 May 2009 20:34:30 +0200 (CEST)'] 22DBF281BDE 24524 1 2009-05-01 mailer-daemon id6a488197511655bc@bounced.tld ------------------------------------------------------- --------QID --SIZE NUM YYYY-MM-DD SENDER (envelope) RECIPIENTS (envelope) date: DATE (HEADER) Listed 6 messages.
Hold, release, requeue and rm
These subcommands allow you to take action on a set of queued messages.
Suppose one of your server admins has set up freeradius half way and makes the mistake of running radwatch(8) and that server doesn't have an accessible mta and directs root mail to an invalid address. The next morning you might have thousands of undeliverable bounces on your mail servers. To get rid of them you might call:
% postqm -i recipient eq root@radius.oursite.tld \ -i sender eq mailer-daemon hold 2B1A1281A3A held 3128728196A held 495902819AE held [. . .] B04BE281A30 held Requested 4834 messages to be held. % postqm -i recipient eq root@radius.oursite.tld \ -i sender eq mailer-daemon rm 2B1A1281A3A DELETED!! 3128728196A DELETED!! 495902819AE DELETED!! [. . .] B04BE281A30 DELETED!! Requested deletion of 4834 messages.
Next time your mail queues overflow the reason might be less benign. For instance a legitimate news letter for thousands of your users might have managed to get past your throttling but you can't very well delete these messages. To temporarily put them on hold you would call:
% postqm -i sender eq bounce@mlsite.tld hold 6104B281A78 held 45E18281B8C held E86B228194E held [. . .] 921BB281A53 held Requested 5492 messages to be held.
And later when your mail servers have some more cycles to spare you can release them with:
% postqm -i sender eq bounce@mlsite.tld \ -i held eq True release 6104B281A78 released 45E18281B8C released E86B228194E released [. . .] 921BB281A53 released Requested the release of 5492 messages.
Download
See the download page for distribution tarballs and git access.