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. The message may contain an mbox-style
24       From_ line before the first header line. If the message does not
25       contain a From_ line, maildrop will create one (if needed).
26
27       If the file /etc/maildroprc exists, mail delivery or mail filtering
28       instructions are read from that file.  maildrop's delivery/filtering
29       instructions may direct maildrop to save the message in specific
30       mailbox, discard it, return it to sender, or forward it to a different
31       E-mail address.
32
33       If /etc/maildroprc does not exist, or its mail delivery instructions do
34       not completely dispose of this message, maildrop then reads the mail
35       delivery instructions from $HOME/.mailfilter. If it doesn't exist, or
36       its mail delivery instructions do not completely dispose of the
37       message, maildrop then saves the E-mail message in the default mailbox.
38
39       maildrop knows how to deliver mail to an standard mailbox files; it
40       also knows how to deliver to maildirs. A maildir is a directory-based
41       mail format used by the Courier[1] and Qmail[2] mail servers. Many
42       other mail servers also know how to read maildirs. When delivering to
43       mailbox files, maildrop will lock the mailbox for the duration of the
44       delivery.
45
46       At least one mail program writes an empty line before a From_ header
47       when saving a message into a file.  maildrop ignores empty lines at the
48       beginning of messages. Therefore, maildrop requires that every message
49       must have at least one header line.
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           (after /etc/maildroprc) and follows the instructions in it. Unless
60           the message is explicitly forwarded, bounced, deleted, or delivered
61           to a specific mailbox, it will be delivered to the user's system
62           mailbox.
63
64       Delivery mode
65
66           maildrop is the mail server's mail delivery agent.  maildrop runs
67           in delivery mode when no filename is specified on the command line.
68           maildrop changes the current directory to the user's home
69           directory, then reads /etc/maildroprc, then $HOME/.mailfilter.
70
71       Embedded mode
72
73           maildrop functions as a part of another application. The embedded
74           mode is used by the Courier[1] mail server to integrate mail
75           filtering directly into the process of receiving mail from a remote
76           mail relay, thus rejecting unwanted mail before it is even accepted
77           for local mail delivery. Embedded mode is used when either the -m,
78           or the -M, option is specified, and is described below. See below
79           for a more extensive description of the embedded mode.
80

SECURITY

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

TEMPORARY FILES

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

OPTIONS

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

DELIVERY MODE

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

VIRTUAL ACCOUNTS

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

EMBEDDED MODE

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

WATCHDOG TIMER

347       maildrop has a watchdog timer that attempts to abort runaway filtering.
348       If filtering is not complete within a predefined time interval (defined
349       by the system administrator, usually five minutes), maildrop
350       terminates.
351

FILES

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

SEE ALSO

375       lockmail(1)[15], maildropfilter(7)[16], makedat(1)[17],
376       maildropgdbm(7)[9], maildropex(7)[18], reformail(1)[19],
377       makemime(1)[20], reformime(1)[21], egrep(1), grep(1), , courier(8)[22],
378       sendmail(8), http://www.qmail.org.
379

REFERENCES

381        1. Courier
382           http://www.courier-mta.org
383
384        2. Qmail
385           http://www.qmail.org
386
387        3. "Environment"
388           maildropfilter.html#environment
389
390        4. "Variable substitution"
391           maildropfilter.html#varsubst
392
393        5. is passed the -m or the -M option.
394           #options
395
396        6. cc
397           maildropfilter.html#cc
398
399        7. dotlock
400           maildropfilter.html#dotlock
401
402        8. flock
403           maildropfilter.html#flock
404
405        9. gdbmopen
406           maildropgdbm.html
407
408       10. log
409           maildropfilter.html#log
410
411       11. to
412           maildropfilter.html#to
413
414       12. xfilter
415           maildropfilter.html#xfilter
416
417       13. echo
418           maildropfilter.html#echo
419
420       14. include
421           maildropfilter.html#include
422
423       15. lockmail(1)
424           lockmail.html
425
426       16. maildropfilter(7)
427           maildropfilter.html
428
429       17. makedat(1)
430           makedat.html
431
432       18. maildropex(7)
433           maildropex.html
434
435       19. reformail(1)
436           reformail.html
437
438       20. makemime(1)
439           makemime.html
440
441       21. reformime(1)
442           reformime.html
443
444       22. courier(8)
445           courier.html
446
447
448
449Double Precision, Inc.            04/22/2007                       MAILDROP(1)
Impressum