1MAILDROP(1)                 Double Precision, Inc.                 MAILDROP(1)
2
3
4

NAME

6       maildrop - mail delivery filter/agent
7

SYNOPSIS

9       maildrop [option...] [-d user] [arg...]
10
11       maildrop [option...] [filename] [arg...]
12

DESCRIPTION

14       maildrop is a replacement local mail delivery agent that includes a
15       mail filtering language. The system administrator can either replace
16       the existing mail delivery agent with maildrop, or users may run
17       maildrop using the 'forward to program' mechanism of the existing mail
18       delivery agent.
19
20       maildrop first reads the E-mail message on standard input. Trailing
21       carriage return characters are automatically stripped. An E-mail
22       message consists of header lines, followed by a blank line, followed by
23       the contents of the message.
24
25       maildrop does not accept an mbox-style From_ line before the first
26       header line.  maildrop does not accept leading empty lines before the
27       first non-blank header line. If the message can possibly start with
28       empty lines, and a From_ line, use reformail -f0 to remove any initial
29       empty lines, and replace a From_ line with a proper “Return-Path:”
30       header; then pipe it to maildrop.
31
32       If the file /etc/maildroprc exists, mail delivery or mail filtering
33       instructions are read from that file.  maildrop's delivery/filtering
34       instructions may direct maildrop to save the message in specific
35       mailbox, discard it, return it to sender, or forward it to a different
36       E-mail address.
37
38       If /etc/maildroprc does not exist, or its mail delivery instructions do
39       not completely dispose of this message, maildrop then reads the mail
40       delivery instructions from $HOME/.mailfilter. If it doesn't exist, or
41       its mail delivery instructions do not completely dispose of the
42       message, maildrop then saves the E-mail message in the default mailbox.
43
44       maildrop knows how to deliver mail to an standard mailbox files; it
45       also knows how to deliver to maildirs. A maildir is a directory-based
46       mail format used by the Courier[1] and Qmail[2] mail servers. Many
47       other mail servers also know how to read maildirs. When delivering to
48       mailbox files, maildrop will lock the mailbox for the duration of the
49       delivery.
50
51       This is the general mail delivery behavior. There are minor differences
52       in behavior depending on maildrop delivery mode, which is determined
53       based on how maildrop was started.  maildrop uses three different
54       primary operating modes:
55
56       Manual mode
57           A file containing filtering instructions - filename is specified as
58           an argument to the maildrop command.  maildrop reads this filename
59           and follows the instructions in it. Unless the message is
60           explicitly forwarded, bounced, deleted, or delivered to a specific
61           mailbox, it will be delivered to the user's system mailbox.
62
63       Delivery mode
64           maildrop is the mail server's mail delivery agent.  maildrop runs
65           in delivery mode when no filename is specified on the command line.
66           maildrop changes the current directory to the user's home
67           directory, then reads /etc/maildroprc, then $HOME/.mailfilter.
68
69       Embedded mode
70           maildrop functions as a part of another application. The embedded
71           mode is used by the Courier[1] mail server to integrate mail
72           filtering directly into the process of receiving mail from a remote
73           mail relay, thus rejecting unwanted mail before it is even accepted
74           for local mail delivery. Embedded mode is used when either the -m,
75           or the -M, option is specified, and is described below. See below
76           for a more extensive description of the embedded mode.
77

SECURITY

79       It is safe to install maildrop as a root setuid program.  The Courier
80       mail server[1] installs maildrop as a root setuid program by default,
81       in order to be able to use maildrop in embedded mode. If root runs
82       maildrop (or it is setuided to root) the -d option may be used to
83       specify the message's recipient.  maildrop immediately resets its
84       userid to the one specified by the -d option. The user's
85       $HOME/.mailfilter is read (if it exists), and the message is delivered
86       to the indicated user.
87
88       The system administrator can configure maildrop to restrict the -d
89       option for everyone except the mail system itself.
90
91       If in delivery mode the user's home directory has the sticky bit set,
92       maildrop immediately terminates with an exit code of EX_TEMPFAIL,
93       without doing anything. Mail servers interpret the EX_TEMPFAIL exit
94       code as a request to reschedule the message for another delivery
95       attempt later. Setting the sticky bit allows $HOME/.mailfilter to be
96       edited while temporarily holding all incoming mail.
97
98       maildrop also terminates with EX_TEMPFAIL if the user's home directory
99       has world write permissions.
100
101       maildrop immediately terminates with EX_TEMPFAIL if the filename is not
102       owned by the user, or if it has any group or world permissions. This
103       includes read permissions. The permissions on $HOME/.mailfilter may
104       only include read and write privileges to the user.
105
106       When using the special embedded mode (see below) maildrop immediately
107       terminates with the exit code set to EX_TEMPFAIL if $HOME/.mailfilters
108       is not owned by the user, or if it has any group or world permissions.
109

TEMPORARY FILES

111       maildrop is heavily optimized and tries to use as little resources as
112       possible.  maildrop reads small messages into memory, then filters
113       and/or delivers the message directly from memory. For larger messages,
114       maildrop accesses the message directly from the file. If the standard
115       input is not a file, maildrop writes the message to a temporary file,
116       then accesses the message from the temporary file. The temporary file
117       is automatically removed when the message is delivered.
118

OPTIONS

120       -a
121           Makes the Courier Authentication Library usage mandatory, i.e.
122           maildrop will throw a temporary error code if the call to the
123           authlib mechanism fails for some reason, such as authdaemon being
124           inaccessible.
125
126               Note
127               This setting may already be the default, depending on
128               maildrop's configuration.
129
130       -A "Header: value"
131           Adds an additional header to the message. Specifying -A "Foo: Bar"
132           effectively adds this header to the message being delivered.
133
134           The mail transport agent usually adds additional headers when
135           delivering a message to a local mailbox. The way it's usually done
136           is by the mail transport agent sending the message using a pipe to
137           the local delivery agent - such as maildrop - and adding some
138           additional headers in the process. Because maildrop receives the
139           message from a pipe, maildrop must either save the message in
140           memory or write the message into a temporary file.
141
142           The -A option enables the file containing the message to be
143           provided to maildrop directly, as standard input, and the
144           additional headers specified on the command line. Because the
145           standard input is a file, maildrop will not need a temporary file.
146           Multiple -A options may be specified.
147
148       -d user
149           Run maildrop in delivery mode for this user ID.
150
151           The system administrator may optionally restrict the -d option to
152           be available to the mail system only, so it may not be available to
153           you. In all cases, the -d option is allowed if user is the same
154           user who is running maildrop. Also, for the -d option to work at
155           all, maildrop must be executed by root, or maildrop must be a
156           root-owned program with the setuid bit set. Absence of a filename
157           on maildrop's command line implies the -d option for the user
158           running maildrop.
159
160           If -d is not specified, the first argument following all the
161           options is a name of the file containing filtering instructions.
162           The remaining arguments, if any, are assigned to the variables $1,
163           $2, and so on (see "Environment"[3] and "Variable
164           substitution"[4]).
165
166       -f address
167           Sets the FROM variable (message envelope sender) to address. The
168           system administrator may optionally disable the -f option for
169           users, so it may not be available to you.
170
171       -m
172           Run maildrop in embedded mode. It's possible to use both the -m,
173           and the -d options, but it doesn't make much sense to do so. Even
174           if you really wanted to run your message through someone else's
175           .mailfilter, that .mailfilter probably has at least one instruction
176           which is not allowed in the embedded mode.
177
178           The filename argument to maildrop should be specified.  filename is
179           a file that includes filtering instructions to be processed in
180           embedded mode. The -m option is used for debugging filter files
181           which are later placed in $HOME/.mailfilters, and used with the -M
182           option.
183
184       -M filterfile
185           Run maildrop in a special embedded mode. The -d option is implied
186           when -M is used, and if absent it defaults to the userid running
187           maildrop.
188
189           All the requirements for the -d option apply.  maildrop must either
190           be executed by root, or the maildrop program must be owned by root
191           with the setuid bit set.  maildrop immediately gives up root
192           privileges by changing its user ID to the one specified by -d, then
193           reads $HOME/.mailfilters/filterfile. For security reasons the name
194           of the file may not begin with a slash or include periods.
195           maildrop is very paranoid: both $HOME/.mailfilters, and
196           $HOME/.mailfilters/filterfile must be owned by the user, and may
197           not have any group or world permissions.
198
199           The -M option allows for some friendly cooperation between the user
200           running the application, and the user who provides a filter for the
201           embedded mode. The user running the application can use someone
202           else's canned filter and be assured that the filter is not going to
203           run amok and start sending mail or create files all over the place.
204           The user who provides the filter can be assured that the
205           environment variables are clean, and that there are no surprises.
206
207           maildrop supports the concept of "default" filter files. If the
208           file specified by the -M option cannot be found in
209           $HOME/.mailfilters, maildrop will try to open
210           $HOME/.mailfilters/filterfileprefix-default.  filterfileprefix is
211           the initial part of filterfile up until the last '-' character in
212           filterfile.
213
214           If $HOME/.mailfilters/filterfileprefix-default does not exist, and
215           there are any other dashes left in filterfileprefix, maildrop
216           removes the last dash and everything following it, then tries
217           again.
218
219           As a last resort maildrop tries to open $HOME/.mailfilters/default.
220
221           For example, if the parameter to the -M option is
222           mailfilter-lists-maildrop, maildrop will try to open the following
223           files, in order:
224
225           Note that maildrop looks for -default files ONLY if -M is used.
226
227       -D uuu/ggg
228           This option is reserved for use by the version of maildrop that
229           comes integrated with the Courier mail server[1].
230
231       -V level
232           Initialize the VERBOSE variable to level. Because maildrop parses
233           the entire file before running it, this option is used to produce
234           debugging output in the parsing phase. Otherwise, if filename has
235           syntax errors, then no debugging output is possible because the
236           VERBOSE variable is not yet set.
237
238           -V is ignored when maildrop runs in delivery mode.
239
240       -w N
241           The -w N option places a warning message into the maildir if the
242           maildir has a quota setting, and after the message was successfully
243           delivered the maildir was at least N percent full.
244
245       -W filename
246           Copy the warning message from filename, or from /etc/quotawarnmsg
247           if this option is not specified, with the addition of the "Date:"
248           and "Message-Id:" headers. The warning is repeated every 24 hours
249           (at least), until the maildir drops below N percent full.
250
251       -t socket
252           This option is available if maildrop is compiled with optional
253           Dovecot authentication support.  socket specifies the location of
254           Dovecot master authentication socket, for example
255           /var/run/dovecot/auth-master.
256

DELIVERY MODE

258       If a filename is not specified on the command line, or if the -d option
259       is used, maildrop will run in delivery mode. In delivery mode, maildrop
260       changes to the home directory of the user specified by the -d option
261       (or the user who is running maildrop if the -d option was not given)
262       and reads $HOME/.mailfilter for filtering instructions.
263       $HOME/.mailfilter must be owned by the user, and have no group or
264       global permissions (maildrop terminates if it does).
265
266       If $HOME/.mailfilter does not exist, maildrop will simply deliver the
267       message to the user's mailbox.
268
269       If the file /etc/maildroprc exists, maildrop reads filtering
270       instructions from this file first, before reading $HOME/.mailfilter.
271       This allows the system administrator to provide global filtering
272       instructions for all users.
273
274           Note
275           /etc/maildroprc is read only in delivery mode.
276

VIRTUAL ACCOUNTS

278       The -d option can also specify a name of a virtual account or mailbox.
279       See the makeuserdb(1) manual page in the Courier Authentication
280       library's documentation for more information.
281

EMBEDDED MODE

283       The embedded mode is used when maildrop's filtering abilities are
284       desired, but no actual mail delivery is needed. In embedded mode
285       maildrop is executed by another application, and is passed the ‐m or
286       the ‐M option.[5] maildrop reads the message, then runs the filtering
287       rules specified in filename.
288
289       filename may contain any filtering instructions EXCEPT the following:
290
291       ` ... `
292           Text strings delimited by back-tick characters (run shell command)
293           are not allowed.
294
295       cc[6]
296           The cc command is not allowed in embedded mode.
297
298       dotlock[7]
299           The dotlock command is not allowed in embedded mode.
300
301       flock[8]
302           The flock command is not allowed in embedded mode.
303
304       gdbmopen[9]
305           In embedded mode, GDBM databases may be opened only for reading.
306
307       log[10]
308           The log command is not allowed in embedded mode.
309
310       logfile[10]
311           The logfile command is not allowed in embedded mode.
312
313       system[11]
314           The system command is not allowed in embedded mode.
315
316       to[12]
317           The to command is not allowed in embedded mode.
318
319       xfilter[13]
320           The xfilter command is not allowed in embedded mode.
321
322       Normally when the filename does not explicitly delivers a message,
323       maildrop will deliver the message to the user's default mailbox. This
324       is also disabled in embedded mode.
325
326       The filename may communicate with the parent application by using the
327       echo[14] statement and the EXITCODE environment variable.
328
329   /etc/maildroprcs
330       If maildrop encounters an include[15] statement where the filename
331       starts with /etc/maildroprcs/, the normal restrictions for the embedded
332       mode are suspended while executing the filter file in the
333       /etc/maildroprcs directory. The restrictions are also suspended for any
334       additional filter files that are included from /etc/maildroprcs. The
335       restrictions resume once maildrop finishes executing the file from
336       /etc/maildroprcs.
337
338       This allows the system administrator to have a controlled environment
339       for running external commands (via the backticks, the system[11] or the
340       xfilter[13] commands).
341
342       The name of the file may not contain any periods (so that a creative
343       individual can't write include
344       "/etc/maildroprcs/../../home/user/recipe").
345
346       Before executing the commands in the /etc/maildroprcs file, maildrop
347       automatically resets the following variables to their initial values:
348       DEFAULT, HOME, LOCKEXT, LOCKSLEEP, LOCKTIMEOUT, LOCKREFRESH, LOGNAME,
349       PATH, SENDMAIL, and SHELL. Please note that the previous values of
350       these variables (if they were changed) will NOT be restored once
351       maildrop finishes executing the commands from /etc/maildroprcs.
352

WATCHDOG TIMER

354       maildrop has a watchdog timer that attempts to abort runaway filtering.
355       If filtering is not complete within a predefined time interval (defined
356       by the system administrator, usually five minutes), maildrop
357       terminates.
358

FILES

360       /etc/passwd
361           Sets user's home directory, and related variables. If NIS/YP is
362           install, that will be used as well.
363
364       /etc/maildroprc
365           Global filtering instructions for delivery mode.
366
367       /var/mail
368           System mailbox (actual directory defined by the system
369           administrator).
370
371       /usr/lib/sendmail
372           Program to forward mail (exact program defined by the system
373           administrator).
374
375       $HOME/.mailfilter
376           Filtering instructions in delivery mode.
377
378       $HOME/.mailfilters
379           Directory containing files used in special embedded mode.
380

SEE ALSO

382       lockmail(1)[16], maildropfilter(7)[17], makedat(1)[18],
383       maildropgdbm(7)[9], maildropex(7)[19], reformail(1)[20],
384       makemime(1)[21], reformime(1)[22], egrep(1), grep(1), , courier(8)[23],
385       sendmail(8), http://www.qmail.org.
386

AUTHOR

388       Sam Varshavchik
389           Author
390

NOTES

392        1. Courier
393           http://www.courier-mta.org
394
395        2. Qmail
396           http://www.qmail.org
397
398        3. "Environment"
399           http://www.courier-mta.org/maildrop/maildropfilter.html#environment
400
401        4. "Variable substitution"
402           http://www.courier-mta.org/maildrop/maildropfilter.html#varsubst
403
404        5. is passed the ‐m or the ‐M option.
405           http://www.courier-mta.org/maildrop/#options
406
407        6. cc
408           http://www.courier-mta.org/maildrop/maildropfilter.html#cc
409
410        7. dotlock
411           http://www.courier-mta.org/maildrop/maildropfilter.html#dotlock
412
413        8. flock
414           http://www.courier-mta.org/maildrop/maildropfilter.html#flock
415
416        9. gdbmopen
417           http://www.courier-mta.org/maildrop/maildropgdbm.html
418
419       10. log
420           http://www.courier-mta.org/maildrop/maildropfilter.html#log
421
422       11. system
423           http://www.courier-mta.org/maildrop/maildropfilter.html#system
424
425       12. to
426           http://www.courier-mta.org/maildrop/maildropfilter.html#to
427
428       13. xfilter
429           http://www.courier-mta.org/maildrop/maildropfilter.html#xfilter
430
431       14. echo
432           http://www.courier-mta.org/maildrop/maildropfilter.html#echo
433
434       15. include
435           http://www.courier-mta.org/maildrop/maildropfilter.html#include
436
437       16. lockmail(1)
438           http://www.courier-mta.org/maildrop/lockmail.html
439
440       17. maildropfilter(7)
441           http://www.courier-mta.org/maildrop/maildropfilter.html
442
443       18. makedat(1)
444           http://www.courier-mta.org/maildrop/makedat.html
445
446       19. maildropex(7)
447           http://www.courier-mta.org/maildrop/maildropex.html
448
449       20. reformail(1)
450           http://www.courier-mta.org/maildrop/reformail.html
451
452       21. makemime(1)
453           http://www.courier-mta.org/maildrop/makemime.html
454
455       22. reformime(1)
456           http://www.courier-mta.org/maildrop/reformime.html
457
458       23. courier(8)
459           http://www.courier-mta.org/maildrop/courier.html
460
461
462
463Courier Mail Server               02/16/2018                       MAILDROP(1)
Impressum