chiark / gitweb /
Merge branches 'idx/verh' and 'idx/qmqpc'
[qmail] / dot-qmail.9
CommitLineData
2117e02e
MW
1.TH dot-qmail 5
2.SH NAME
3dot-qmail \- control the delivery of mail messages
4.SH DESCRIPTION
5Normally the
6.B qmail-local
7program delivers each incoming message to your system mailbox,
8.IR homedir\fB/Mailbox ,
9where
10.I homedir
11is your home directory.
12
13It can instead
14write the mail to a different file or directory,
15forward it to another address,
16distribute it to a mailing list,
17or even execute programs,
18all under your control.
19.SH "THE QMAIL FILE"
20To change
21.BR qmail-local 's
22behavior, set up a
23.B .qmail
24file in your home directory.
25
26.B .qmail
27contains one or more lines.
28Each line is a delivery instruction.
29.B qmail-local
30follows each instruction in turn.
31There are five types of delivery instructions:
32(1) comment; (2) program; (3) forward; (4) mbox; (5) maildir.
33.TP 5
34(1)
35A comment line begins with a number sign:
36
37.EX
38 # this is a comment
39.EE
40
41.B qmail-local
42ignores the line.
43.TP 5
44(2)
45A program line begins with a vertical bar:
46
47.EX
212b6f5d 48 |preline /usr/ucb/vacation djb
2117e02e
MW
49.EE
50
51.B qmail-local
52takes the rest of the line as a command to supply to
53.BR sh .
54See
55.B qmail-command(8)
56for further information.
57.TP 5
58(3)
59A forward line begins with an ampersand:
60
61.EX
62 &me@new.job.com
63.EE
64
65.B qmail-local
66takes the rest of the line as a mail address;
67it uses
68.B qmail-queue
69to forward the message to that address.
70The address must contain a fully qualified domain name;
71it must not contain extra spaces, angle brackets, or comments:
72
73.EX
74 # the following examples are WRONG
75.br
76 &me@new
77.br
78 &<me@new.job.com>
79.br
80 & me@new.job.com
81.br
82 &me@new.job.com (New Address)
83.EE
84
85If the address begins with a letter or number,
86you may leave out the ampersand:
87
88.EX
89 me@new.job.com
90.EE
91
92Note that
93.B qmail-local
94omits its new
95.B Return-Path
96line when forwarding messages.
97.TP 5
98(4)
99An
100.I mbox
101line begins with a slash or dot,
102and does not end with a slash:
103
104.EX
105 /home/djb/Mailbox.sos
106.EE
107
108.B qmail-local
109takes the entire line as a filename.
110It appends the mail message to that file,
111using
112.BR flock -style
113file locking if possible.
114.B qmail-local
115stores the mail message in
116.I mbox
117format, as described in
118.BR mbox(5) .
119
120.B WARNING:
121On many systems,
122anyone who can read a file can
123.B flock
124it, and thus hold up
125.BR qmail-local 's
126delivery forever.
127Do not deliver mail to a publicly accessible file!
128
129If
130.B qmail-local
131is able to lock the file, but has trouble writing to it
132(because, for example, the disk is full),
133it will truncate the file back to its original length.
134However, it cannot prevent mailbox corruption if the system
135crashes during delivery.
136.TP 5
137(5)
138A
139.I maildir
140line begins with a slash or dot,
141and ends with a slash:
142
143.EX
144 /home/djb/Maildir/
145.EE
146
147.B qmail-local
148takes the entire line as the name of a directory in
149.I maildir
150format.
151It reliably stores the incoming message in that directory.
152See
153.B maildir(5)
154for more details.
155.PP
156If
157.B .qmail
158has the execute bit set,
159it must not contain any
160program lines,
161.I mbox
162lines,
163or
164.I maildir
165lines.
166If
167.B qmail-local
168sees any such lines,
169it will stop and indicate a temporary failure.
170
171If
172.B .qmail
173is completely empty (0 bytes long), or does not exist,
174.B qmail-local
175follows the
212b6f5d 176.I defaultdelivery
2117e02e
MW
177instructions set by your system administrator;
178normally
212b6f5d 179.I defaultdelivery
2117e02e
MW
180is
181.BR ./Mailbox ,
182so
183.B qmail-local
184appends the mail message to
185.B Mailbox
186in
187.I mbox
188format.
189
190.B .qmail
191may contain extra spaces and tabs at the end of a line.
192Blank lines are allowed, but not for the first line of
193.BR .qmail .
194
195If
196.B .qmail
197is world-writable or group-writable,
198.B qmail-local
199stops and indicates a temporary failure.
200.SH "SAFE QMAIL EDITING"
201Incoming messages can arrive at any moment.
202If you want to safely edit your
203.B .qmail
204file, first set the sticky bit on your home directory:
205
206.EX
207 chmod +t $HOME
208.EE
209
210.B qmail-local
211will temporarily defer delivery of any message to you
212if your home directory is sticky
213(or group-writable or other-writable,
214which should never happen).
215Make sure to
216
217.EX
218 chmod -t $HOME
219.EE
220
221when you are done!
222It's a good idea to test your new
223.B .qmail
224file as follows:
225
226.EX
212b6f5d 227 qmail-local -n $USER ~ $USER '' '' '' '' ./Mailbox
2117e02e
MW
228.EE
229.SH "EXTENSION ADDRESSES"
230In the
231.B qmail
232system,
233you control all local addresses of the form
234.IR user\fBBREAK\fIanything ,
235as well as the address
236.I user
237itself,
238where
239.I user
240is your account name.
241Delivery to
242.I user\fBBREAK\fIanything
243is controlled by the file
244.IR homedir/\fB.qmail\-\fIanything .
245(These rules may be changed by the system administrator;
246see
247.BR qmail-users (5).)
248
249The
250.B alias
251user controls all other addresses.
252Delivery to
253.I local
254is controlled by the file
255.IR homedir/\fB.qmail\-\fIlocal ,
256where
257.I homedir
258is
259.BR alias 's
260home directory.
261
262In the following description,
263.B qmail-local
264is handling a message addressed to
265.IR local@domain ,
266where
267.I local
268is controlled by
269.BR .qmail\-\fIext .
270Here is what it does.
271
272If
273.B .qmail\-\fIext
274is completely empty,
275.B qmail-local
276follows the
212b6f5d 277.I defaultdelivery
2117e02e
MW
278instructions set by your system administrator.
279
280If
281.B .qmail\-\fIext
282doesn't exist,
283.B qmail-local
284will try some default
285.B .qmail
286files.
287For example,
288if
289.I ext
290is
291.BR foo-bar ,
292.B qmail-local
293will try first
294.BR .qmail-foo-bar ,
295then
296.BR .qmail-foo-default ,
297and finally
298.BR .qmail-default .
299If none of these exist,
300.B qmail-local
301will bounce the message.
302(Exception: for the basic
303.I user
304address,
305.B qmail-local
306treats a nonexistent
307.B .qmail
308the same as an empty
309.BR .qmail .)
310
311.B WARNING:
312For security,
313.B qmail-local
314replaces any dots in
315.I ext
316with colons before checking
317.BR .qmail\-\fIext .
318For convenience,
319.B qmail-local
320converts any uppercase letters in
321.I ext
322to lowercase.
323
324When
325.B qmail-local
326forwards a message as instructed in
327.B .qmail\-\fIext
328(or
329.BR .qmail-default ),
330it checks whether
331.B .qmail\-\fIext\fB-owner\fP
332exists.
333If so,
334it uses
335.I local\fB-owner@\fIdomain
336as the envelope sender for the forwarded message.
337Otherwise it retains the envelope sender of the original message.
338Exception:
339.B qmail-local
340always retains the original envelope sender
341if it is the empty address or
342.BR #@[] ,
343i.e., if this is a bounce message.
344
345.B qmail-local
346also supports
347.B variable envelope return paths
348(VERPs):
349if
350.B .qmail\-\fIext\fB-owner\fP
351and
352.B .qmail\-\fIext\fB-owner-default\fP
353both exist, it uses
354.I local\fB\-owner\-@\fIdomain\fB-@[]
355as the envelope sender.
356This will cause a recipient
357.I recip\fB@\fIreciphost
358to see an envelope sender of
359.IR local\fB\-owner\-\fIrecip\fB=\fIreciphost\fB@\fIdomain .
360.SH "ERROR HANDLING"
361If a delivery instruction fails,
362.B qmail-local
363stops immediately and reports failure.
364.B qmail-local
365handles forwarding after all other instructions,
366so any error in another type of delivery will prevent all forwarding.
367
368If a program returns exit code 99,
369.B qmail-local
370ignores all succeeding lines in
371.BR .qmail ,
372but it still pays attention to previous forward lines.
373
374To set up independent instructions,
375where a temporary or permanent failure in one instruction
376does not affect the others,
377move each instruction into a separate
378.B .qmail\-\fIext
379file, and set up a central
380.B .qmail
381file that forwards to all of the
382.BR .qmail\-\fIext s.
383Note that
384.B qmail-local
385can handle any number of forward lines simultaneously.
386.SH "SEE ALSO"
387envelopes(5),
388maildir(5),
389mbox(5),
390qmail-users(5),
391qmail-local(8),
392qmail-command(8),
393qmail-queue(8),
394qmail-lspawn(8)