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