{
    "mode": "man",
    "parameter": "maildrop",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/maildrop/1/json",
    "generated": "2026-10-05T05:02:58Z",
    "synopsis": "maildrop [option...] [-d user] [arg...]\nmaildrop [option...] [filename] [arg...]",
    "sections": {
        "NAME": {
            "content": "maildrop - mail delivery filter/agent\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "maildrop [option...] [-d user] [arg...]\n\nmaildrop [option...] [filename] [arg...]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "maildrop is a replacement local mail delivery agent that includes a mail filtering language.\nThe system administrator can either replace the existing mail delivery agent with maildrop,\nor users may run maildrop using the 'forward to program' mechanism of the existing mail\ndelivery agent.\n\nmaildrop first reads the E-mail message on standard input. Trailing carriage return\ncharacters are automatically stripped. An E-mail message consists of header lines, followed\nby a blank line, followed by the contents of the message.\n\nmaildrop does not accept an mbox-style From line before the first header line.  maildrop\ndoes not accept leading empty lines before the first non-blank header line. If the message\ncan possibly start with empty lines, and a From line, use reformail -f0 to remove any\ninitial empty lines, and replace a From line with a proper “Return-Path:” header; then pipe\nit to maildrop.\n\nIf the file /etc/maildroprc exists, mail delivery or mail filtering instructions are read\nfrom that file.  maildrop's delivery/filtering instructions may direct maildrop to save the\nmessage in specific mailbox, discard it, return it to sender, or forward it to a different\nE-mail address.\n\nIf /etc/maildroprc does not exist, or its mail delivery instructions do not completely\ndispose of this message, maildrop then reads the mail delivery instructions from\n$HOME/.mailfilter. If it doesn't exist, or its mail delivery instructions do not completely\ndispose of the message, maildrop then saves the E-mail message in the default mailbox.\n\nmaildrop knows how to deliver mail to an standard mailbox files; it also knows how to deliver\nto maildirs. A maildir is a directory-based mail format used by the Courier[1] and Qmail[2]\nmail servers. Many other mail servers also know how to read maildirs. When delivering to\nmailbox files, maildrop will lock the mailbox for the duration of the delivery.\n\nThis is the general mail delivery behavior. There are minor differences in behavior depending\non maildrop delivery mode, which is determined based on how maildrop was started.  maildrop\nuses three different primary operating modes:\n\nManual mode\nA file containing filtering instructions - filename is specified as an argument to the\nmaildrop command.  maildrop reads this filename (after /etc/maildroprc) and follows the\ninstructions in it. Unless the message is explicitly forwarded, bounced, deleted, or\ndelivered to a specific mailbox, it will be delivered to the user's system mailbox.\n\nDelivery mode\nmaildrop is the mail server's mail delivery agent.  maildrop runs in delivery mode when\nno filename is specified on the command line.  maildrop changes the current directory to\nthe user's home directory, then reads /etc/maildroprc, then $HOME/.mailfilter.\n\nEmbedded mode\nmaildrop functions as a part of another application. The embedded mode is used by the\nCourier[1] mail server to integrate mail filtering directly into the process of receiving\nmail from a remote mail relay, thus rejecting unwanted mail before it is even accepted\nfor local mail delivery. Embedded mode is used when either the -m, or the -M, option is\nspecified, and is described below. See below for a more extensive description of the\nembedded mode.\n",
            "subsections": []
        },
        "SECURITY": {
            "content": "It is safe to install maildrop as a root setuid program.  The Courier mail server[1] installs\nmaildrop as a root setuid program by default, in order to be able to use maildrop in embedded\nmode. If root runs maildrop (or it is setuided to root) the -d option may be used to specify\nthe message's recipient.  maildrop immediately resets its userid to the one specified by the",
            "subsections": [
                {
                    "name": "-d",
                    "content": "to the indicated user.\n\nThe system administrator can configure maildrop to restrict the -d option for everyone except\nthe mail system itself.\n\nIf in delivery mode the user's home directory has the sticky bit set, maildrop immediately\nterminates with an exit code of EXTEMPFAIL, without doing anything. Mail servers interpret\nthe EXTEMPFAIL exit code as a request to reschedule the message for another delivery attempt\nlater. Setting the sticky bit allows $HOME/.mailfilter to be edited while temporarily holding\nall incoming mail.\n\nmaildrop also terminates with EXTEMPFAIL if the user's home directory has world write\npermissions.\n\nmaildrop immediately terminates with EXTEMPFAIL if the filename is not owned by the user, or\nif it has any group or world permissions. This includes read permissions. The permissions on\n$HOME/.mailfilter may only include read and write privileges to the user.\n\nWhen using the special embedded mode (see below) maildrop immediately terminates with the\nexit code set to EXTEMPFAIL if $HOME/.mailfilters is not owned by the user, or if it has any\ngroup or world permissions.\n",
                    "flag": "-d"
                }
            ]
        },
        "TEMPORARY FILES": {
            "content": "maildrop is heavily optimized and tries to use as little resources as possible.  maildrop\nreads small messages into memory, then filters and/or delivers the message directly from\nmemory. For larger messages, maildrop accesses the message directly from the file. If the\nstandard input is not a file, maildrop writes the message to a temporary file, then accesses\nthe message from the temporary file. The temporary file is automatically removed when the\nmessage is delivered.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-a",
                    "content": "Makes the Courier Authentication Library usage mandatory, i.e. maildrop will throw a\ntemporary error code if the call to the authlib mechanism fails for some reason, such as\nauthdaemon being inaccessible.\n\nNote\nThis setting may already be the default, depending on maildrop's configuration.\n\n-A \"Header: value\"\nAdds an additional header to the message. Specifying -A \"Foo: Bar\" effectively adds this\nheader to the message being delivered.\n\nThe mail transport agent usually adds additional headers when delivering a message to a\nlocal mailbox. The way it's usually done is by the mail transport agent sending the\nmessage using a pipe to the local delivery agent - such as maildrop - and adding some\nadditional headers in the process. Because maildrop receives the message from a pipe,\nmaildrop must either save the message in memory or write the message into a temporary\nfile.\n\nThe -A option enables the file containing the message to be provided to maildrop\ndirectly, as standard input, and the additional headers specified on the command line.\nBecause the standard input is a file, maildrop will not need a temporary file. Multiple\n-A options may be specified.\n\n-d user\nRun maildrop in delivery mode for this user ID.\n\nThe system administrator may optionally restrict the -d option to be available to the\nmail system only, so it may not be available to you. In all cases, the -d option is\nallowed if user is the same user who is running maildrop. Also, for the -d option to work\nat all, maildrop must be executed by root, or maildrop must be a root-owned program with\nthe setuid bit set. Absence of a filename on maildrop's command line implies the -d\noption for the user running maildrop.\n\nIf -d is not specified, the first argument following all the options is a name of the\nfile containing filtering instructions. The remaining arguments, if any, are assigned to\nthe variables $1, $2, and so on (see \"Environment\"[3] and \"Variable substitution\"[4]).\n\n-f address\nSets the FROM variable (message envelope sender) to address. The system administrator may\noptionally disable the -f option for users, so it may not be available to you.\n",
                    "flag": "-a"
                },
                {
                    "name": "-m",
                    "content": "Run maildrop in embedded mode. It's possible to use both the -m, and the -d options, but\nit doesn't make much sense to do so. Even if you really wanted to run your message\nthrough someone else's .mailfilter, that .mailfilter probably has at least one\ninstruction which is not allowed in the embedded mode.\n\nThe filename argument to maildrop should be specified.  filename is a file that includes\nfiltering instructions to be processed in embedded mode. The -m option is used for\ndebugging filter files which are later placed in $HOME/.mailfilters, and used with the -M\noption.\n\n-M filterfile\nRun maildrop in a special embedded mode. The -d option is implied when -M is used, and if\nabsent it defaults to the userid running maildrop.\n\nAll the requirements for the -d option apply.  maildrop must either be executed by root,\nor the maildrop program must be owned by root with the setuid bit set.  maildrop\nimmediately gives up root privileges by changing its user ID to the one specified by -d,\nthen reads $HOME/.mailfilters/filterfile. For security reasons the name of the file may\nnot begin with a slash or include periods.  maildrop is very paranoid: both\n$HOME/.mailfilters, and $HOME/.mailfilters/filterfile must be owned by the user, and may\nnot have any group or world permissions.\n\nThe -M option allows for some friendly cooperation between the user running the\napplication, and the user who provides a filter for the embedded mode. The user running\nthe application can use someone else's canned filter and be assured that the filter is\nnot going to run amok and start sending mail or create files all over the place. The user\nwho provides the filter can be assured that the environment variables are clean, and that\nthere are no surprises.\n\nmaildrop supports the concept of \"default\" filter files. If the file specified by the -M\noption cannot be found in $HOME/.mailfilters, maildrop will try to open\n$HOME/.mailfilters/filterfileprefix-default.  filterfileprefix is the initial part of\nfilterfile up until the last '-' character in filterfile.\n\nIf $HOME/.mailfilters/filterfileprefix-default does not exist, and there are any other\ndashes left in filterfileprefix, maildrop removes the last dash and everything following\nit, then tries again.\n\nAs a last resort maildrop tries to open $HOME/.mailfilters/default.\n\nFor example, if the parameter to the -M option is mailfilter-lists-maildrop, maildrop\nwill try to open the following files, in order:\n\nNote that maildrop looks for -default files ONLY if -M is used.\n\n-D uuu/ggg\nThis option is reserved for use by the version of maildrop that comes integrated with the\nCourier mail server[1].\n\n-V level\nInitialize the VERBOSE variable to level. Because maildrop parses the entire file before\nrunning it, this option is used to produce debugging output in the parsing phase.\nOtherwise, if filename has syntax errors, then no debugging output is possible because\nthe VERBOSE variable is not yet set.\n\n-V is ignored when maildrop runs in delivery mode.\n\n-w N\nThe -w N option places a warning message into the maildir if the maildir has a quota\nsetting, and after the message was successfully delivered the maildir was at least N\npercent full.\n\n-W filename\nCopy the warning message from filename, or from /etc/quotawarnmsg if this option is not\nspecified, with the addition of the \"Date:\" and \"Message-Id:\" headers. The warning is\nrepeated every 24 hours (at least), until the maildir drops below N percent full.\n\n-t socket\nThis option is available if maildrop is compiled with optional Dovecot authentication\nsupport.  socket specifies the location of Dovecot master authentication socket, for\nexample /var/run/dovecot/auth-master.\n",
                    "flag": "-m"
                }
            ]
        },
        "DELIVERY MODE": {
            "content": "If a filename is not specified on the command line, or if the -d option is used, maildrop\nwill run in delivery mode. In delivery mode, maildrop changes to the home directory of the\nuser specified by the -d option (or the user who is running maildrop if the -d option was not\ngiven) and reads $HOME/.mailfilter for filtering instructions.  $HOME/.mailfilter must be\nowned by the user, and have no group or global permissions (maildrop terminates if it does).\n\nIf $HOME/.mailfilter does not exist, maildrop will simply deliver the message to the user's\nmailbox.\n\nIf the file /etc/maildroprc exists, maildrop reads filtering instructions from this file\nfirst, before reading $HOME/.mailfilter. This allows the system administrator to provide\nglobal filtering instructions for all users.\n\nNote\n\n/etc/maildroprc is read only in delivery mode.\n",
            "subsections": []
        },
        "VIRTUAL ACCOUNTS": {
            "content": "The -d option can also specify a name of a virtual account or mailbox. See the makeuserdb(1)\nmanual page in the Courier Authentication library's documentation for more information.\n",
            "subsections": []
        },
        "EMBEDDED MODE": {
            "content": "The embedded mode is used when maildrop's filtering abilities are desired, but no actual mail\ndelivery is needed. In embedded mode maildrop is executed by another application, and is\npassed the ‐m or the ‐M option.[5] maildrop reads the message, then runs the filtering rules\nspecified in filename.\n\nfilename may contain any filtering instructions EXCEPT the following:\n\n` ... `\nText strings delimited by back-tick characters (run shell command) are not allowed.\n\ncc[6]\nThe cc command is not allowed in embedded mode.\n\ndotlock[7]\nThe dotlock command is not allowed in embedded mode.\n\nflock[8]\nThe flock command is not allowed in embedded mode.\n\ngdbmopen[9]\nIn embedded mode, GDBM databases may be opened only for reading.\n\nlog[10]\nThe log command is not allowed in embedded mode.\n\nlogfile[10]\nThe logfile command is not allowed in embedded mode.\n\nsystem[11]\nThe system command is not allowed in embedded mode.\n\nto[12]\nThe to command is not allowed in embedded mode.\n\nxfilter[13]\nThe xfilter command is not allowed in embedded mode.\n\nNormally when the filename does not explicitly delivers a message, maildrop will deliver the\nmessage to the user's default mailbox. This is also disabled in embedded mode.\n\nThe filename may communicate with the parent application by using the echo[14] statement and\nthe EXITCODE environment variable.\n",
            "subsections": [
                {
                    "name": "/etc/maildroprcs",
                    "content": "If maildrop encounters an include[15] statement where the filename starts with\n/etc/maildroprcs/, the normal restrictions for the embedded mode are suspended while\nexecuting the filter file in the /etc/maildroprcs directory. The restrictions are also\nsuspended for any additional filter files that are included from /etc/maildroprcs. The\nrestrictions resume once maildrop finishes executing the file from /etc/maildroprcs.\n\nThis allows the system administrator to have a controlled environment for running external\ncommands (via the backticks, the system[11] or the xfilter[13] commands).\n\nThe name of the file may not contain any periods (so that a creative individual can't write\ninclude \"/etc/maildroprcs/../../home/user/recipe\").\n\nBefore executing the commands in the /etc/maildroprcs file, maildrop automatically resets the\nfollowing variables to their initial values: DEFAULT, HOME, LOCKEXT, LOCKSLEEP, LOCKTIMEOUT,\nLOCKREFRESH, LOGNAME, PATH, SENDMAIL, and SHELL. Please note that the previous values of\nthese variables (if they were changed) will NOT be restored once maildrop finishes executing\nthe commands from /etc/maildroprcs.\n"
                }
            ]
        },
        "WATCHDOG TIMER": {
            "content": "maildrop has a watchdog timer that attempts to abort runaway filtering. If filtering is not\ncomplete within a predefined time interval (defined by the system administrator, usually five\nminutes), maildrop terminates.\n",
            "subsections": []
        },
        "FILES": {
            "content": "/etc/passwd\nSets user's home directory, and related variables. If NIS/YP is install, that will be\nused as well.\n\n/etc/maildroprc\nGlobal filtering instructions for delivery mode.\n\n/var/mail\nSystem mailbox (actual directory defined by the system administrator).\n\n/usr/sbin/sendmail\nProgram to forward mail (exact program defined by the system administrator).\n\n$HOME/.mailfilter\nFiltering instructions in delivery mode.\n\n$HOME/.mailfilters\nDirectory containing files used in special embedded mode.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "lockmail(1)[16], maildropfilter(7)[17], makedat(1)[18], maildropgdbm(7)[9],\nmaildropex(7)[19], reformail(1)[20], makemime(1)[21], reformime(1)[22], egrep(1), grep(1), ,\ncourier(8)[23], sendmail(8), http://www.qmail.org.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "",
            "subsections": [
                {
                    "name": "Sam Varshavchik",
                    "content": "Author\n"
                }
            ]
        },
        "NOTES": {
            "content": "1. Courier\nhttp://www.courier-mta.org\n\n2. Qmail\nhttp://www.qmail.org\n\n3. \"Environment\"\nhttp://www.courier-mta.org/maildrop/maildropfilter.html#environment\n\n4. \"Variable substitution\"\nhttp://www.courier-mta.org/maildrop/maildropfilter.html#varsubst\n\n5. is passed the ‐m or the ‐M option.\nhttp://www.courier-mta.org/maildrop/#options\n\n6. cc\nhttp://www.courier-mta.org/maildrop/maildropfilter.html#cc\n\n7. dotlock\nhttp://www.courier-mta.org/maildrop/maildropfilter.html#dotlock\n\n8. flock\nhttp://www.courier-mta.org/maildrop/maildropfilter.html#flock\n\n9. gdbmopen\nhttp://www.courier-mta.org/maildrop/maildropgdbm.html\n\n10. log\nhttp://www.courier-mta.org/maildrop/maildropfilter.html#log\n\n11. system\nhttp://www.courier-mta.org/maildrop/maildropfilter.html#system\n\n12. to\nhttp://www.courier-mta.org/maildrop/maildropfilter.html#to\n\n13. xfilter\nhttp://www.courier-mta.org/maildrop/maildropfilter.html#xfilter\n\n14. echo\nhttp://www.courier-mta.org/maildrop/maildropfilter.html#echo\n\n15. include\nhttp://www.courier-mta.org/maildrop/maildropfilter.html#include\n\n16. lockmail(1)\nhttp://www.courier-mta.org/maildrop/lockmail.html\n\n17. maildropfilter(7)\nhttp://www.courier-mta.org/maildrop/maildropfilter.html\n\n18. makedat(1)\nhttp://www.courier-mta.org/maildrop/makedat.html\n\n19. maildropex(7)\nhttp://www.courier-mta.org/maildrop/maildropex.html\n\n20. reformail(1)\nhttp://www.courier-mta.org/maildrop/reformail.html\n\n21. makemime(1)\nhttp://www.courier-mta.org/maildrop/makemime.html\n\n22. reformime(1)\nhttp://www.courier-mta.org/maildrop/reformime.html\n\n23. courier(8)\nhttp://www.courier-mta.org/maildrop/courier.html\n\nCourier Mail Server                          07/24/2017                                  MAILDROP(1)",
            "subsections": []
        }
    },
    "summary": "maildrop - mail delivery filter/agent",
    "flags": [
        {
            "flag": "-a",
            "long": null,
            "arg": null,
            "description": "Makes the Courier Authentication Library usage mandatory, i.e. maildrop will throw a temporary error code if the call to the authlib mechanism fails for some reason, such as authdaemon being inaccessible. Note This setting may already be the default, depending on maildrop's configuration. -A \"Header: value\" Adds an additional header to the message. Specifying -A \"Foo: Bar\" effectively adds this header to the message being delivered. The mail transport agent usually adds additional headers when delivering a message to a local mailbox. The way it's usually done is by the mail transport agent sending the message using a pipe to the local delivery agent - such as maildrop - and adding some additional headers in the process. Because maildrop receives the message from a pipe, maildrop must either save the message in memory or write the message into a temporary file. The -A option enables the file containing the message to be provided to maildrop directly, as standard input, and the additional headers specified on the command line. Because the standard input is a file, maildrop will not need a temporary file. Multiple -A options may be specified. -d user Run maildrop in delivery mode for this user ID. The system administrator may optionally restrict the -d option to be available to the mail system only, so it may not be available to you. In all cases, the -d option is allowed if user is the same user who is running maildrop. Also, for the -d option to work at all, maildrop must be executed by root, or maildrop must be a root-owned program with the setuid bit set. Absence of a filename on maildrop's command line implies the -d option for the user running maildrop. If -d is not specified, the first argument following all the options is a name of the file containing filtering instructions. The remaining arguments, if any, are assigned to the variables $1, $2, and so on (see \"Environment\"[3] and \"Variable substitution\"[4]). -f address Sets the FROM variable (message envelope sender) to address. The system administrator may optionally disable the -f option for users, so it may not be available to you."
        },
        {
            "flag": "-m",
            "long": null,
            "arg": null,
            "description": "Run maildrop in embedded mode. It's possible to use both the -m, and the -d options, but it doesn't make much sense to do so. Even if you really wanted to run your message through someone else's .mailfilter, that .mailfilter probably has at least one instruction which is not allowed in the embedded mode. The filename argument to maildrop should be specified. filename is a file that includes filtering instructions to be processed in embedded mode. The -m option is used for debugging filter files which are later placed in $HOME/.mailfilters, and used with the -M option. -M filterfile Run maildrop in a special embedded mode. The -d option is implied when -M is used, and if absent it defaults to the userid running maildrop. All the requirements for the -d option apply. maildrop must either be executed by root, or the maildrop program must be owned by root with the setuid bit set. maildrop immediately gives up root privileges by changing its user ID to the one specified by -d, then reads $HOME/.mailfilters/filterfile. For security reasons the name of the file may not begin with a slash or include periods. maildrop is very paranoid: both $HOME/.mailfilters, and $HOME/.mailfilters/filterfile must be owned by the user, and may not have any group or world permissions. The -M option allows for some friendly cooperation between the user running the application, and the user who provides a filter for the embedded mode. The user running the application can use someone else's canned filter and be assured that the filter is not going to run amok and start sending mail or create files all over the place. The user who provides the filter can be assured that the environment variables are clean, and that there are no surprises. maildrop supports the concept of \"default\" filter files. If the file specified by the -M option cannot be found in $HOME/.mailfilters, maildrop will try to open $HOME/.mailfilters/filterfileprefix-default. filterfileprefix is the initial part of filterfile up until the last '-' character in filterfile. If $HOME/.mailfilters/filterfileprefix-default does not exist, and there are any other dashes left in filterfileprefix, maildrop removes the last dash and everything following it, then tries again. As a last resort maildrop tries to open $HOME/.mailfilters/default. For example, if the parameter to the -M option is mailfilter-lists-maildrop, maildrop will try to open the following files, in order: Note that maildrop looks for -default files ONLY if -M is used. -D uuu/ggg This option is reserved for use by the version of maildrop that comes integrated with the Courier mail server[1]. -V level Initialize the VERBOSE variable to level. Because maildrop parses the entire file before running it, this option is used to produce debugging output in the parsing phase. Otherwise, if filename has syntax errors, then no debugging output is possible because the VERBOSE variable is not yet set. -V is ignored when maildrop runs in delivery mode. -w N The -w N option places a warning message into the maildir if the maildir has a quota setting, and after the message was successfully delivered the maildir was at least N percent full. -W filename Copy the warning message from filename, or from /etc/quotawarnmsg if this option is not specified, with the addition of the \"Date:\" and \"Message-Id:\" headers. The warning is repeated every 24 hours (at least), until the maildir drops below N percent full. -t socket This option is available if maildrop is compiled with optional Dovecot authentication support. socket specifies the location of Dovecot master authentication socket, for example /var/run/dovecot/auth-master."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "lockmail",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/lockmail/1/json"
        },
        {
            "name": "maildropfilter",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/maildropfilter/7/json"
        },
        {
            "name": "makedat",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/makedat/1/json"
        },
        {
            "name": "maildropgdbm",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/maildropgdbm/7/json"
        },
        {
            "name": "maildropex",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/maildropex/7/json"
        },
        {
            "name": "reformail",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/reformail/1/json"
        },
        {
            "name": "makemime",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/makemime/1/json"
        },
        {
            "name": "reformime",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/reformime/1/json"
        },
        {
            "name": "egrep",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/egrep/1/json"
        },
        {
            "name": "grep",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/grep/1/json"
        },
        {
            "name": "courier",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/courier/8/json"
        },
        {
            "name": "sendmail",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/sendmail/8/json"
        }
    ],
    "tldr": {
        "source": "not_found",
        "examples": []
    }
}