Browse Source

Adding AUTHORS, COPYING, README
Adding manual page
Adding build system (makefile)
Minor fixes and improvements in code

Emmanuel Bouthenot 16 years ago
parent
commit
db00de6d5f
6 changed files with 179 additions and 15 deletions
  1. 4 0
      AUTHORS
  2. 14 0
      COPYING
  3. 14 0
      Makefile
  4. 19 0
      README
  5. 15 15
      pmailq
  6. 113 0
      pmailq.pod

+ 4 - 0
AUTHORS

@@ -0,0 +1,4 @@
+pmail - Postfix mail queue manager
+==================================
+
+Main developer : Emmanuel Bouthenot <kolter@openics.org>

+ 14 - 0
COPYING

@@ -0,0 +1,14 @@
+            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+                    Version 2, December 2004
+
+ Copyright (C) 2004 Sam Hocevar
+  14 rue de Plaisance, 75014 Paris, France
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. You just DO WHAT THE FUCK YOU WANT TO.
+

+ 14 - 0
Makefile

@@ -0,0 +1,14 @@
+
+MANPAGE_SECTION = 8
+
+all: man
+
+man: pmailq.${MANPAGE_SECTION}
+
+pmailq.${MANPAGE_SECTION}: pmailq.pod
+	pod2man --center "" --date "" --release "" --section=${MANPAGE_SECTION} pmailq.pod > pmailq.${MANPAGE_SECTION}
+
+clean:
+	rm -f pmailq.${MANPAGE_SECTION}
+
+.PHOMY: man

+ 19 - 0
README

@@ -0,0 +1,19 @@
+pmail - Postfix mail queue manager
+==================================
+
+pmailq : Postfix MAIL Queue manager
+
+see manpage for more informations
+
+Features
+--------
+(see manpage)
+
+Copyright
+---------
+(see AUTHORS file)
+
+Licence
+-------
+pmailq is distributed under WTFPL
+(see COPYING file for complete license)

+ 15 - 15
pmailq

@@ -9,7 +9,7 @@
 
 
 _NAME = 'pmailq'
-_HELP = "[OPTIONS] [ show | showcsv | del ]"
+_HELP = "[OPTIONS] [ list | parse | del ]"
 _DESC = "%s postfix mail queue manager" % _NAME
 _VERSION = '0.1'
 _AUTHOR = 'Emmanuel Bouthenot <kolter@openics.org>'
@@ -125,7 +125,7 @@ class mailqueue:
         return True
 
 
-    def show(self):
+    def cmd_list(self):
         for m in self.mailqueue:
             out = "%s\n" % m['id'] 
             out += "  -date: %s\n" % m['date']
@@ -144,7 +144,7 @@ class mailqueue:
                 print out
 
         
-    def showcsv(self):
+    def cmd_parse(self):
         for m in self.mailqueue:
             e = []
             i = []
@@ -157,7 +157,7 @@ class mailqueue:
                     print "%s|%s|%s|%d|%d|%s" % (m['id'], m['date'], m['size'], int(m['active']), int(m['hold']),  ",".join(n['dest']))
 
 
-    def delete(self):
+    def cmd_del(self):
         for m in self.mailqueue:
             e = []
             i=[]
@@ -179,16 +179,16 @@ def main():
     parser = OptionParser(usage=usage, description=desc, version=("%s %s" % (_NAME, _VERSION)))
 
     opts = OptionGroup(parser, "filters")
-    opts.add_option("-e", "--email", dest="email", type="string", metavar="EMAIL", help="select entries in queue with email matching EMAIL")
+    opts.add_option("-e", "--email", dest="email", type="string", metavar="PATTERN", help="select entries in queue with email matching PATTERN")
     parser.set_defaults(email=None)
-    opts.add_option("-m", "--msg", dest="msg", type="string", metavar="MSG", help="select entries in queue with error message matching MSG")
+    opts.add_option("-m", "--msg", dest="msg", type="string", metavar="PATTERN", help="select entries in queue with error message matching PATTERN")
     parser.set_defaults(msg=None)
-    opts.add_option("-l", "--size-lower", dest="lowsize", type="int", metavar="SIZE", help="select entries in queue with size smaller than SIZE")
+    opts.add_option("-l", "--size-lower", dest="lowsize", type="int", metavar="SIZE", help="select entries in queue with size lower than SIZE bytes")
     parser.set_defaults(lowsize=0)
-    opts.add_option("-u", "--size-upper", dest="upsize", type="int", metavar="SIZE", help="select entries in queue with size upper than SIZE")
+    opts.add_option("-u", "--size-upper", dest="upsize", type="int", metavar="SIZE", help="select entries in queue with size upper than SIZE bytes")
     parser.set_defaults(upsize=0)
     opts.add_option("-a", "--active", dest="active", default=False, action="store_true", help="select 'active' entries in queue (default: no)")
-    opts.add_option("-o", "--hold", dest="hold", default=False, action="store_true", help="select on 'hold' entries in queue (default: no)")
+    opts.add_option("-o", "--hold", dest="hold", default=False, action="store_true", help="select 'on hold' entries in queue (default: no)")
     parser.add_option_group(opts)
 
     (options, args) = parser.parse_args()
@@ -202,13 +202,13 @@ def main():
     m.add_filter("hold", options.hold)
 
     if args == []:
-        m.show()
-    elif args[0] == "show":
-        m.show()
-    elif args[0] == "showcsv":
-        m.showcsv()
+        m.cmd_list()
+    elif args[0] == "list":
+        m.cmd_list()
+    elif args[0] == "parse":
+        m.cmd_parse()
     elif args[0] == "del":
-        m.delete()
+        m.cmd_del()
     else:
         print "%s %s" % (_NAME, _HELP)
 

+ 113 - 0
pmailq.pod

@@ -0,0 +1,113 @@
+=head1 NAME
+
+pmailq - Postfix MAIL Queue manager
+
+=head1 SYNOPSIS
+
+pmailq [I<OPTION>]... [I<COMMAND>]
+
+pmailq B<--help>
+
+=head1 DESCRIPTION
+
+pmailq parse output of B<mailq> command from postfix (ie: I<postqueue -p>) to perform some
+actions on selected entries. The selected entries are filtered by applying filters on criterias
+like email address, error message from smtp server, message size, mail state in queue.
+
+=head1 COMMANDS
+
+Action to perform on selected entries.
+
+=over 2
+
+=item B<list> (default command) 
+
+show a detailed listing of the selected entries
+
+=item B<parse> 
+
+show a listing of the selected entries in a machine readable format
+
+=item B<del> 
+
+delete (via I<postsuper -d>) selected entries
+
+=head1 OPTIONS
+
+=over 2
+
+=item B<-e> I<PATTERN>, B<--email>=I<PATTERN>
+
+select entries in queue with email matching PATTERN
+
+=item B<-m> I<PATTERN>, B<--msg>=I<PATTERN>
+
+select entries in queue with error message matching PATTERN
+
+=item B<-l> I<SIZE>, B<--size-lower>=I<SIZE>
+
+select entries in queue with size lower than SIZE bytes
+
+=item B<-u> I<SIZE>, B<--size-upper>=I<SIZE>
+
+select entries in queue with size upper than SIZE bytes
+
+=item B<-a>
+
+select 'active' entries in queue
+
+=item B<-o>
+
+select 'on hold' entries in queue
+
+=item B<--version>
+
+show program's version number and exit
+
+=item B<-h>, B<--help>
+
+show this help message and exit
+
+=head1 EXAMPLES
+
+=over 1
+
+Example n°1 : display all the mails in queue to "*@example.com*" with a size between 3000 and 3200 bytes in a machine readable format :
+
+ # pmailq -u 3000 -l 3200 -e "*@example.com" parse
+ 7E75214643A4|Fri Aug 31|3154|1|0|edgar@example.com
+ B0BDE146B640|Thu Aug 30|3199|1|0|paul@example.com
+ B587E146B675|Wed Aug 29|3065|0|0|paul@example.com
+ CF3C514656E4|Wed Aug 29|3161|0|0|abuse@example.com
+      /\         /\       /\  \  \      
+   queue id     date     size  \  \ on hold (or not)
+                                \ active (or not)
+
+Example n°2 : remove all mails in queue not sent because of a connection time out :
+
+ # pmailq -m "*connection*timed*out" del
+ deleting 00CF514616D3 [OK]
+ deleting 12D911461924 [OK]
+ deleting 269EF1461CA9 [OK]
+ deleting 288DF1461CA0 [OK]
+ deleting 3B3901460F62 [OK]
+ deleting 3AE58147019F [OK]
+
+=head1 SEE ALSO
+
+L<postsuper(1)> privileged queue operations, L<postqueue(1)> mail queue control
+
+=head1 AUTHOR
+
+Emmanuel Bouthenot <kolter@openics.org>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2007 by Emmanuel Bouthenot <kolter@openics.org>
+
+This program is released under the "do What The Fuck you want to Public Licence"
+Version 2, as published by Sam Hocevar.
+
+See http://sam.zoy.org/wtfpl/COPYING for more details.
+
+=cut