maildrop
Deliver email to local mailboxes
SYNOPSIS
maildrop [-d user] [-f sender] [-a account] [-M file] [-V variable=value] [size_limit]
Common usage often involves piping mail to it:
/usr/sbin/sendmail -i -oem -f sender recipient | maildrop
PARAMETERS
-d user
Delivers mail for the specified user. Essential for system-wide delivery.
-f sender
Sets the envelope sender for the message, used for identification.
-a account
Specifies the account name for Maildir quota calculations.
-A header
Appends an additional header to the message before filtering.
-M file
Uses an alternate file as the maildroprc script instead of the default.
-L N
Sets the logging level to N (numeric), for verbose output or debugging.
-m
Prevents mail delivery if the maildroprc script encounters an error.
-V variable=value
Sets a custom variable with a given value for the maildroprc script.
-c
Checks the syntax of the maildroprc file and exits, without processing mail.
-w N
Sets the maximum bytes N for xfilter or xexec command output.
-t
Enables test mode; mail is processed but not actually delivered.
-E
Disables enforcement of Maildir quota limits during delivery.
-R
Prevents the execution of the global maildroprc configuration file.
-U uid
Sets the User ID (uid) for the maildroprc script process.
-G gid
Sets the Group ID (gid) for the maildroprc script process.
DESCRIPTION
maildrop is a highly configurable local mail delivery agent (MDA) designed for Unix-like systems. It reads an email message, typically from standard input, and processes it based on a set of rules defined in a configuration file, most commonly .maildroprc in the user's home directory.
maildrop excels at filtering, sorting, and automatically managing incoming email. It can deliver mail to various mailbox formats, including the robust Maildir format or traditional mbox files. Additionally, it can forward mail, execute external programs (e.g., spam/virus scanners), send auto-replies, and perform complex mail transformations. Its powerful, scriptable language allows users to implement sophisticated mail processing logic, making it a versatile tool for both individual mail management and server-side filtering.
CAVEATS
Security: Care must be taken with .maildroprc scripts, especially when allowing arbitrary commands via xfilter or xexec. Malicious scripts could execute unwanted commands with the user's permissions or escalate privileges if maildrop runs with elevated rights.
Performance: Complex .maildroprc scripts involving many external commands can impact mail delivery performance, particularly on busy mail servers.
Maildir vs. mbox: maildrop is heavily optimized for the Maildir format, offering greater robustness. While it can deliver to mbox, Maildir is generally recommended for better integrity and performance.
CONFIGURATION FILE (<I>.MAILDROPRC</I>)
The primary configuration for maildrop is defined in a file named .maildroprc, typically located in the user's home directory. This file contains a sequence of rules written in maildrop's specialized scripting language. These rules dictate how incoming mail is processed, including filtering based on headers or body content, delivering to specific folders, forwarding, sending auto-replies, or executing external programs. A global configuration, often found at /etc/maildroprc, can also be present.
MAILDIR FORMAT
maildrop is engineered with robust support for the Maildir format, a structured directory system for storing email. Unlike the mbox format, which aggregates all messages into a single file, Maildir stores each email as a unique file within a specific directory structure (tmp, new, cur). This design inherently avoids mail locking issues, prevents corruption, and offers improved efficiency, especially in environments with concurrent access or high volumes of mail.
ENVIRONMENT VARIABLES
Within the .maildroprc script, maildrop automatically sets several environment variables, such as FROM, TO, RECIPIENT, and SENDER. These variables provide crucial contextual information about the email currently being processed, enabling scripts to make decisions based on message metadata. Users can also define custom variables for their scripts using the -V option.
HISTORY
maildrop was developed by Sam Varshavchik as an integral component of the Courier Mail Server project. It emerged as a powerful and secure alternative to existing mail delivery agents like procmail, distinguished by its strong, native support for the Maildir format. Maildir, which stores each email in a separate file, offers significant advantages such as atomicity (reducing mail corruption risk) and superior performance for large mailboxes compared to the traditional mbox format. maildrop's design prioritized providing a robust and highly scriptable solution for local mail filtering and delivery, solidifying its position as a favored choice among both individual users and system administrators.


