# maildrop - mail delivery agent with filtering abilities

Current development version is 2.0.0, stable version is @PREVIOUS_VERSION@.

Copyright 1998-2003, Double Precision Inc.

This program is distributed under the terms of the GNU General Public License. See `COPYING` for additional information.

## Where to find maildrop

Join the maildrop mailing list - `http://lists.sourceforge.net/lists/listinfo/courier-maildrop`.

I've started a list of "tips and tricks" for writing mail filters with maildrop.

The HTML version of the maildrop README is located at `http://www.courier-mta.org/maildrop/`. Although the following files may also be found there, please check your favorite archive for any local copies:

The STABLE version of maildrop:

`maildrop-@PREVIOUS_VERSION@.tar.gz` - the source code tarball.

`maildrop-@PREVIOUS_VERSION@-1.src.rpm`- the distribution source code in the RPM format. To build a binary RPM run the command `rpm --rebuild maildrop-@PREVIOUS_VERSION@-1.src.rpm`.

`maildrop-@PREVIOUS_VERSION@-1.i386.rpm` - pre-built binary RPM for Red Hat Linux. Please note that the binary RPM's configuration includes the `--enable-restrict-trusted=0` flag: a relaxed security level which allows all users to use the -d option to maildrop. Maildrop's default, strict, security model may result in sendmail temporarily deferring local mail (it will be eventually delivered). See `INSTALL` for more information. If your system does not require relaxed security, you may rebuild the source RPM (after making the appropriate adjustment to the .spec file).

The DEVELOPMENT version of maildrop:

`maildrop-2.0.0.tar.gz`

`maildrop-2.0.0-1.src.rpm`

`maildrop-2.0.0-1.i386.rpm`

The RPMs are signed with my GnuPG key: `http://www.geocities.com/SiliconValley/Peaks/5799/GPGKEY.txt`.

maildrop includes documentation in HTML, as well as traditional man pages. The HTML versions may also be found at `http://www.courier-mta.org/maildrop/maildrop.html.`

## Introduction

maildrop is a replacement for your local mail delivery agent. maildrop reads a mail message from standard input, then delivers the message to your mailbox. maildrop knows how to deliver mail to mbox-style mailboxes, and maildirs. "maildir" is a mailbox format used by the Qmail MTA.

maildrop will optionally read instructions from a file, which describes how to filter incoming mail. Instructions can be provided having mail delivered to alternate mailboxes, or forwarded somewhere else. Unlike procmail, maildrop uses a structured filtering language.

maildrop is written in C++, and is significantly larger than procmail in compiled form. However, it uses resources much more efficiently. Unlike procmail, maildrop will not read a 10 megabyte mail message into memory. Large messages are saved in a temporary file, and are filtered from the temporary file. Temporary files are saved in the user's home directory. If the standard input to maildrop is a file, and not a pipe, a temporary file will not be necessary.

maildrop checks the syntax of the mail delivery instructions the filter file, before attempting to deliver a message. Unlike procmail, if the filter file contains syntax errors, maildrop terminates without delivering the message. The user can fix the typo without causing any mail to be lost.

## Installation

See `INSTALL` for installation information. If you are using an RPM-based GNU/Linux distribution, you can install the binary RPM (see above), or rebuild the source RPM.

## Using maildrop with sendmail

Maildrop can be easily used as sendmail's local delivery agent, instead of procmail. Here is the suggested entry for sendmail.cf, courtesy of Eric J. Schwertfeger <ejs`@`bfd.com>:

    Mlocal,         P=/usr/local/bin/maildrop, F=lsAw5:/|@SPfhn, S=10/30, R=20/40,
                    T=DNS/RFC822/X-Unix,
                    A=maildrop -d $u

You may also consider including the D, F, and M flags as well.

## Revision history (including development versions)

- V0.77 - mostly library update. Some additional sanity checks when delivering to maildirs (checks for rogue soft links -- needed to support delivery to sharable maildirs). maildirmake update - creates sharable maildirs. Added hooks for integrating `maildrop`into Courier.
- V0.75 - new installation layout - will install into /usr/local/lib/maildrop/minor fixes to configuration scripts. Minor typos in userdb. Bug fix: exception statement will now trap maildir quota errors. AIX fixes.
- V0.74- fix compilation errors for SuSE 6.0. Qmail bug fix. userdb update.
- V0.73 - bug fix in getaddr()/hasaddr() functions, and reformail -r option.
- V0.72 - reformime enhancement/update. Maildir support update.
- V0.71 - a maintenance release. Patches for AIX and AFS support. Updates to documentation. Internal cleanup of the source code directory layout, which will allow me to include `maildrop` as parts of other projects. Fixed a bug in the reformime utility.
- V0.70 - option to enable soft enforcement of maildir quotas, see `README.maildirquota` in the maildir subdirectory. Virtual account support. Renamed `makegdbm` to `makedat`. Removed installation option to gzip manual pages -- too messy. Let target platform packagers/porters worry about it. to and cc commands that pipe the message to an external process will now set the `EXITCODE` variable to the exit code of the external process. External processes that terminate with a non-zero exit code will NOT automatically cause maildrop to terminate with the exit code of 75. The exit code will be saved in the `EXITCODE` variable. If the delivery command was `to`, maildrop simply terminates with the same exit code. If the delivery command was `cc`, maildrop continues after initializing `EXITCODE`.
- V0.65 - option to compile Berkeley DB library, instead of GDBM. Added the `import` keyword. Some cleanup of HTML documentation.
- V0.64 - reformime fix - handle systems with broken pipe fseeks semantics. rfc822 library sync. Standardized names of some legacy .h files. Red Hat RPMs changed to install a tiny sh/bash/csh login script (from maildroptips) to purge `$HOME/.tmp`. `makegdbm` can now read from standard input. Some obscure fixes to rfc822 functions. Moved `reformime` to rfc2045 subpackage - it belongs there, and can be shared by other projects.

- V0.63 - maintenance. Minor enhancements and bug fixes to the reformime utility. reformime can now convert 8-bit messages to or from quoted-printable encoding. reformime can now also add missing MIME headers to a message.

- V0.62 - array out of bounds bug fix in rfc822.c. Some additional options to configure to specify various directories. Option to configure to use /usr/local/etc instead of /etc.

- V0.61(prerelease) - rfc822 library sync. Added reformime standalone utility. Added support for GDBM database files. Because GDBM support adds significant amount of code to maildrop, GDBM support can be optionally disabled during installation. Added the time function. Changed how maildrop automatically converts results of floating point mathematical operation back into text - should not affect any existing filters.
  .

- V0.60 - no changes to the main maildrop code from version 0.55c, except for cosmetic changes to some shared modules in order to accomodate the new reformime utility. The main maildrop code appears to be stable. Edited the documentation, and changed the flags that the RPM is built with. NEW: Experimental set of MIME functions, which are implemented as a separate program for now. The reformime program can be used to decode the MIME structure of a message, and extract different parts of it. At some point later, this functionality will be added as native functions in the maildrop filtering language. See `reformime.html` for more information.

- V0.55c - BUG FIX: maildrop would botch the situation where it had problems creating or writing to a temporary file. Fixed error handling so this condition correctly results in deferred mail. Added some sendmail-related notes to `INSTALL`. Added additional punctuation characters recognized by the escape() function. The chance that this would break existing scripts is very remote, but possible, however the additional escaped punctuation would allow the function to be used to hack-proof shell commands.
- V0.55b - enhancement: an optional parameter to configure, `--enable-syslog,` which will enable logging of fatal errors to syslog. sendmail discards standard error, making diagnosis of maildrop problems difficult. An optional switch to configure will have maildrop log all fatal error to syslog. Fixed core dump if `reformail` is given an invalid switch: '-f'.
- V0.55a - fixed some miscellaneous glitches in the configuration script. Fixed potential security problem on some platform with reformail incorrectly being installed with setuid privileges. Only cosmetic changes to the main maildrop program: made some error messages more descriptive; maildrop will now attempt to create a process group upon startup and upon termination maildrop will send a SIGHUP signal to its process group, hopefully terminating any child processes. No bug fixes are known, or have been reported.
- V0.55 - added `HOSTNAME` and `FROM` environment variables. Added -f option. Added support for `/etc/maildroprcs` - see `maildrop(1)`. Fixed obscure bug that can trash a file descriptor.
- V0.54b - Changed auto-configuration logic for enabling dotlocks. If the configure script detects that the system mailbox directly does NOT have the sticky bit set, dot-locks are disabled by default. `--enable-use-dotlock` option to configure can override that. Added --enable-keep-fromline option to preserve the original From_ line address of messages. Note that the default value of this option may change maildrop's behavior from previous versions. See INSTALL for additional information. Documented some additional options to configure that were actually implemented in a previous version. Fixed error in select() logic that may cause the backtick command to fail in some situations.
- V0.54a - miscellaneous fixes. Changed the hasaddr() function to look at `Resent-To:` and `Resent-Cc:`headers. Default `SHELL` to `/bin/sh` if the shell is not specified in `/etc/passwd`. FreeBSD does not support `lockf()` on `/dev/null` - `lockf()` will no longer cause a fatal error if it fails on a character or a block special file. Fixed bug in configure script regarding failed initialization of `--enable-restrict-trusted` flag.
- V0.54 - edited the documentation. Added support for VPATH builds using automake - suggested by Harlan Stenn <Harlan.Stenn`@`pfcs.com>. Major rework of the configuration code. Changed all `#define-`s in config.h to use the `configure` script.
- V0.51c - Fixed the subtraction operator bug. Added sendmail documentation.
- V0.51b - Fixed compilation error for BSD. Fixed spurious "invalid directory permission" error if `$HOME/.mailfilters` does not exist in special embedded mode - maildrop will simply indicate quiet acceptance.
- V0.51 - ported to RedHat 5.1, added `/etc/maildroprc` global filter file.
- V0.50 - first public release.