Kyberdigi Labs

Web Postfix Queue

by C. McCohy <mccohy@kyberdigi.cz>
Web interface to postfix mail queue en
Kyberdigi Labs
Projects
WebQ
Requirements
License
Download
Security
Installation
Configuration
Running
Screenshots
Bugs

Access counter
Counter

Web Postfix Queue

If you are managing a mail server, it can happen that many hundreds of mail messages are there waiting for being delivered in the queue. Of course, you may need to know, who is right now sending the largest message, who send a lot of messages and makes the server slow.

Therefore, most mail daemons include some tool displaying messages in queue and information about them. But if the queue consists of more than 20 different messages, such queue reports are really hard to read.

If you use Postfix as your MTA, we have a better solution for you. A simple perl script parsing output of postfix mailq command and creating HTML page with such possibilities as sorting, filtering, deleting or displaying messages.


Requirements

List of requirements:

Note: Maybe output of the mailq command of other mail software (i.e. sendmail or qmail) is very similar to postfix, but postfix provides very easy control of displaying and deleting messages in queue. So you can use this software even if you are running other MTA and maybe it will work too. Let me know.


License

This software is distributed under the terms of GPL.
Text version available.


Download

You can download one simple tarred and gziped archive via HTTP protocol from this page:

webq-1.0.tar.gz

Size: 13802 bytes
MD5: 46e15f2813f75f2e901da7acd874b5ee


Security

This script can display information about the queue as well as display message contents or silently delete message from the queue. Therefore, you should force this script being secure and accessible to as less people as possible. Be paranoid when installing this script and giving access to someone else.

If you do not want anybody to delete or view messages in queue, set the parameter force_readonly to a non-zero value (see config instruction bellow).

On the other side, if you want to be able to delete or veiw messages in queue, set that variable to zero (this is default) and let the script has the permission to postfix internal files. This could be done if the script is executed from the root user (uid 0) or from the user who runs postfix, usually postfix with uid 51, change this in uid variable.


Installation

First, unpack the archive.
$ tar xzf webq-1.0.tar.gz
Now you should see a directory webq-1.0 so step into it.
$ cd webq-1.0
In this directory, there is the main script: webq.pl.


Configuration

Since this is a very simple script, there are no configuration files attached. If you want to configure the webq.pl script, just edit it with your favourite text editor.

On line 60 (+-) there are two main configuration variables, %postfix and %colors. You should not edit anything else unless you know what you are doing. Now let's take a closer look at these variables.

%postfix:

  • force_readonly - if set to nonzero, the script will never gice you the chance to delete any mail, although you could have a permission to do it
  • hostnamefile - a filename which hold information about the hostname
  • top - number telling the script how many top items should be displayed at the end of the HTML. Set this to '0' to disable this feature
  • method - http method to use in form submitting, should be only 'GET' or 'POST'
  • js_maxselect - because the GET method could generates a really ugly too long URI when deleting a lot of messages, set this to a number your http server can accept, each message = approx. 10 bytes, so i.e. Apache accepts only 1024b long URIs, this number should be about 90. This number has effect only using javascript function for selecting all messages and the GET method
  • mailq - full path to the mailq command
  • postsuper - full path to the postsuper command
  • postcat - full path to the postcat command
  • queue_directory - full path to postfix queue directory
  • uid - uid of the Postfix user

%colors:

  • body_bgcolor - color of HTML background
  • body_text - color of HTML text
  • body_link - color of HTML hyperlink
  • body_vlink - color of visited HTML hyperlink
  • body_alink - color of active HTML hyperlink
  • row_odd_0 - color of unodd row in main table with messages
  • row_odd_1 - color of odd row in main table with messages
  • error - color of error text
  • searchtable - background color of filter table
  • table_head - color of table head row


Running

Fist of all, you have to have running webserver. Apache or Webfs are strongly recommended because of the possibility of securizing acces to this script.

  • Apache

    Configuration of the Apache httpd could be simple or really difficult, this depends on your server configuration. Adding this directives to proper part of httpd.conf should work fine:

    <Directory /path/to/webq-1.0>
      Options ExecCGI
      AddHandler cgi-script .pl
    </Directory>
                          
    Make sure the /path/to/ is accessible via the http protocol. For example, if the /path/to/ is accessible on the URL http://yourhost.tld/mypage/, then URL of the webq.pl script will be http://yourhost.tld/mypage/webq-1.0/web.pl.

    Of course you may want to change this ugly address, i.e. to http://yourhost.tld/webq:

    Alias /webq /path/to/webq-1.0
    <Directory /path/to/webq-1.0>
      Options ExecCGI
      AddHandler cgi-script .pl
      DirectoryIndex webq.pl
    </Directory>
                          

    The information about mail queue could be confidental to other users and worldwide, so you should take care a bit about security. You could for example limit the access to this script to only some IP, protect it with user/password or run it not on the standard http port 80, or run it via encrypted https protocol. See the Apache documentation page for more details, look close at these directives: Allow, Deny, AuthType, Port, SSLEngine.

  • Webfs

    Webfs is very small http daemon without any configuration file, everything neccessary information he gets via parameters on start, run webfsd -h for details. The most important parameter is -x telling webfsd that script in specified directory should not be displayed, but they should displayed.

    If you are not running any http daemon on your server, this is maybe the best solution for you.

    And of course, you should take care about more security of this http daemon access too, so look closer on parameters -j, -p, -b, -S and -x.

  • Other

    Running other http daemon is possible of course. Be sure it is well configured to run scripts properly. The daemon should give to the webq.pl script QUERY_STRING and SCRIPT_NAME variables in its environment.

If you have your http daemon configured and running, access it via its http address, the script should display messages in mail queue.


Screenshots

Webq sample output


Bugs

There are no known bugs at this moment. If you do know about any, please mail me.

Valid HTML 4.01 Kyberdigi Labs