Upstream qmail 1.01
[qmail] / FAQ
CommitLineData
2117e02e
MW
11. Controlling the appearance of outgoing messages
21.1. How do I set up host masquerading?
31.2. How do I set up user masquerading?
4
52. Routing outgoing messages
62.1. How do I send local messages to another host?
72.2. How do I set up a null client?
82.3. How do I send outgoing mail through UUCP?
92.4. How do I set up a separate queue for a SLIP/PPP link?
102.5. How do I deal with ``CNAME lookup failed temporarily''?
11
123. Routing incoming messages by host
133.1. How do I receive mail for another host name?
143.2. How do I set up a virtual domain?
153.3. How do I set up several virtual domains for one user?
16
174. Routing incoming messages by user
184.1. How do I forward unrecognized usernames to another host?
194.2. How do I set up a mailing list?
204.3. How do I use majordomo with qmail?
214.4. How do I use procmail with qmail?
224.5. How do I use elm's filter with qmail?
234.6. How do I create aliases with dots?
24
255. Setting up servers
265.1. How do I run qmail-smtpd under tcpserver?
275.2. How do I set up qmail-qmtpd?
285.3. How do I set up qmail-pop3d?
295.4. How do I allow selected clients to use this host as a relay?
305.5. How do I fix up messages from broken SMTP clients?
31
326. Configuring MUAs to work with qmail
336.1. How do I make BSD mail generate a Date with the local time zone?
346.2. How do I stop pine from crashing?
356.3. How do I make MH work with qmail?
366.4. How do I stop Sun's dtcm from hanging?
37
387. Managing the mail system
397.1. How do I safely stop qmail-send?
407.2. How do I manually run the queue?
417.3. How do I rejuvenate a message?
427.4. How do I organize a big network?
437.5. How do I back up and restore the queue disk?
44
458. Miscellany
468.1. How do I tell qmail to do more deliveries at once?
478.2. How do I keep a copy of all incoming and outgoing mail messages?
488.3. How do I switch slowly from sendmail to qmail?
49
50
51
521. Controlling the appearance of outgoing messages
53
54
551.1. How do I set up host masquerading? All the users on this host,
56zippy.af.mil, are users on af.mil. When joe sends a message to fred, the
57message should say ``From: joe@af.mil'' and ``To: fred@af.mil'', without
58``zippy'' anywhere.
59
60Answer: echo af.mil > /var/qmail/control/defaulthost; chmod 644
61/var/qmail/control/defaulthost.
62
63
641.2. How do I set up user masquerading? I'd like my own From lines to
65show boss@af.mil rather than god@heaven.af.mil.
66
67Answer: Add MAILHOST=af.mil and MAILUSER=boss to your environment. To
68override From lines supplied by your MUA, add QMAILINJECT=f to your
69environment.
70
71
72
732. Routing outgoing messages
74
75
762.1. How do I send local messages to another host? All the mail for
77af.mil should be delivered to our disk server, pokey.af.mil. I've set up
78an MX from af.mil to pokey.af.mil, but when a user on the af.mil host
79sends a message to boss@af.mil, af.mil tries to deliver it locally. How
80do I stop that?
81
82Answer: Remove af.mil from /var/qmail/control/locals. If qmail-send is
83running, give it a HUP. Make sure the MX is set up properly before you
84do this. Also make sure that pokey can receive mail for af.mil---see
85question 3.1.
86
87
882.2. How do I set up a null client? I'd like zippy.af.mil to
89send all mail to bigbang.af.mil.
90
91Answer: echo :bigbang.af.mil > /var/qmail/control/smtproutes;
92chmod 644 /var/qmail/control/smtproutes. Disable local delivery as in
93question 2.1. Turn off qmail-smtpd in /etc/inetd.conf.
94
95
962.3. How do I send outgoing mail through UUCP? I need qmail to send all
97outgoing mail via UUCP to my upstream UUCP site, gonzo.
98
99Answer: Put
100
101 :alias-uucp
102
103into control/virtualdomains and
104
105 |preline -df /usr/bin/uux - -r -gC -a"$SENDER" gonzo!rmail "($EXT2@$HOST)"
106
107into ~alias/.qmail-uucp-default. (For some UUCP software you will need
108to use -d instead of -df. Also, you may need to insert a space between
109-a and "$SENDER" for bounces to work properly.) If qmail-send is
110running, give it a HUP.
111
112
1132.4. How do I set up a separate queue for a SLIP/PPP link?
114
115Answer: Use serialmail (http://pobox.com/~djb/serialmail.html).
116
117
1182.5. How do I deal with ``CNAME lookup failed temporarily''? The log
119showed that a message was deferred for this reason. Why is qmail doing
120CNAME lookups, anyway?
121
122Answer: The SMTP standard does not permit aliased hostnames, so qmail
123has to do a CNAME lookup in DNS for every sender and recipient host. If
124the relevant DNS server is down, qmail defers the message. It will try
125again soon.
126
127
128
1293. Routing incoming messages by host
130
131
1323.1. How do I receive mail for another host name? I'd like our disk
133server, pokey.af.mil, to receive mail addressed to af.mil. I've set up
134an MX from af.mil to pokey.af.mil, but how do I get pokey to treat
135af.mil as a name for the local host?
136
137Answer: Add af.mil to /var/qmail/control/locals and to
138/var/qmail/control/rcpthosts. If qmail-send is running, give it a HUP.
139
140
1413.2. How do I set up a virtual domain? I'd like any mail for
142nowhere.mil, including root@nowhere.mil and postmaster@nowhere.mil and
143so on, to be delivered to Bob. I've set up the MX already.
144
145Answer: Put
146
147 nowhere.mil:bob
148
149into control/virtualdomains. Add nowhere.mil to control/rcpthosts. If
150qmail-send is running, give it a HUP.
151
152Now mail for whatever@nowhere.mil will be delivered locally to
153bob-whatever. Bob can set up ~bob/.qmail-default to catch all the
154possible addresses, ~bob/.qmail-info to catch info@nowhere.mil, etc.
155
156
1573.3. How do I set up several virtual domains for one user? Bob wants
158another virtual domain, everywhere.org, but he wants to handle
159nowhere.mil users and everywhere.org users differently. How can we do
160that without setting up a second account?
161
162Answer: Put two lines into control/virtualdomains:
163
164 nowhere.mil:bob-nowhere
165 everywhere.org:bob-everywhere
166
167Add nowhere.mil and everywhere.org to control/rcpthosts. If qmail-send
168is running, give it a HUP.
169
170Now Bob can set up separate .qmail-nowhere-* and everywhere-* files. He
171can even set up .qmail-nowhere-default and .qmail-everywhere-default.
172
173
174
1754. Routing incoming messages by user
176
177
1784.1. How do I forward unrecognized usernames to another host? I'd like
179to set up a LUSER_RELAY pointing at bigbang.af.mil.
180
181Answer: Put
182
183 | forward "$LOCAL"@bigbang.af.mil
184
185into ~alias/.qmail-default.
186
187
1884.2. How do I set up a mailing list? I'd like me-sos@my.host.name to be
189forwarded to a bunch of people.
190
191Answer: Put a list of addresses into ~me/.qmail-sos, one per line. Then
192incoming mail for me-sos will be forwarded to each of those addresses.
193You should also touch ~me/.qmail-sos-owner so that bounces come back to
194you rather than the original sender. If you want subscriptions to be
195handled automatically, put
196
197 | qlist2 sos my.host.name
198
199into ~me/.qmail-sos-request. Anyone who wants to subscribe can simply
200send a message to me-sos-request@my.host.name.
201
202
2034.3. How do I use majordomo with qmail?
204
205Answer: You need to patch majordomo so that it creates qmail-style
206lists. See ftp://koobera.math.uic.edu/pub/software/majordomo+qmail.gz.
207Exception: qmsmac understands sendmail-style :include: files, so you
208shouldn't patch majordomo if you're using qmsmac.
209
210
2114.4. How do I use procmail with qmail?
212
213Answer: Put
214
215 | preline procmail
216
217into ~/.qmail. You'll have to use a full path for procmail unless
218procmail is in the system's startup PATH. Note that procmail will try to
219deliver to /usr/spool/mail/$USER by default; to change this, change
220SYSTEM_MBOX in procmail's config.h.
221
222
2234.5. How do I use elm's filter with qmail?
224
225Answer: Put
226
227 | preline filter
228
229into ~/.qmail. You'll have to use a full path for filter unless filter
230is in the system's startup PATH.
231
232
2334.6. How do I create aliases with dots? I tried setting up
234~alias/.qmail-P.D.Q.Bach, but it doesn't do anything.
235
236Answer: Use .qmail-p:d:q:bach. Dots are converted to colons, and
237uppercase is converted to lowercase.
238
239
240
2415. Setting up servers
242
243
2445.1. How do I run qmail-smtpd under tcpserver? inetd is barfing at high
245loads, cutting off service for ten-minute stretches. I'd also like
246better connection logging.
247
248Answer: First, install the tcpserver program, part of the ucspi-tcp
249package (http://pobox.com/~djb/ucspi-tcp.html). Second, remove the smtp
250line from /etc/inetd.conf, and put the line
251
252 tcpserver -u 7770 -g 2108 0 smtp /var/qmail/bin/qmail-smtpd &
253
254into your system startup files. Replace 7770 with your qmaild uid, and
255replace 2108 with your nofiles gid. Don't forget the &. The change will
256take effect at your next reboot.
257
258By default, tcpserver allows at most 40 simultaneous qmail-smtpd
259processes. To raise this limit to 400, use tcpserver -c 400. To keep
260track of who's connecting and for how long, run (on two lines)
261
262 tcpserver -v -u 7770 -g 2108 0 smtp /var/qmail/bin/qmail-smtpd \
263 2>&1 | /var/qmail/bin/splogger smtpd 3 &
264
265
2665.2. How do I set up qmail-qmtpd?
267
268Answer: Two steps. First, put a
269
270 qmtp 209/tcp
271
272line into /etc/services. Second, put (all on one line)
273
274 qmtp stream tcp nowait qmaild
275 /var/qmail/bin/tcp-env tcp-env /var/qmail/bin/qmail-qmtpd
276
277into /etc/inetd.conf, and give inetd a HUP.
278
279If you have tcpserver installed, skip the inetd step, and set up
280
281 tcpserver -u 7770 -g 2108 0 qmtp /var/qmail/bin/qmail-qmtpd &
282
283replacing 7770 and 2108 with the qmaild uid and nofiles gid. See
284question 5.1 for more details.
285
286
2875.3. How do I set up qmail-pop3d?
288
289Answer: Four steps. First, install the checkpassword program
290(http://pobox.com/~djb/checkpwd.html). Second, make sure you have a
291
292 pop3 110/tcp
293
294line in /etc/services. Third, put (all on one line)
295
296 pop3 stream tcp nowait root /var/qmail/bin/qmail-popup
297 qmail-popup YOURHOST /bin/checkpassword /var/qmail/bin/qmail-pop3d Maildir
298
299into /etc/inetd.conf, and give inetd a HUP; replace YOURHOST with your
300host's fully qualified domain name. Fourth, set up Maildir delivery for
301any user who wants to read mail via POP.
302
303If you have tcpserver installed, skip the inetd step, and set up (on two
304lines)
305
306 tcpserver 0 pop3 /var/qmail/bin/qmail-popup YOURHOST \
307 /bin/checkpassword /var/qmail/bin/qmail-pop3d Maildir &
308
309replacing YOURHOST with your host's fully qualified domain name. See
310question 5.1 for more details.
311
312Security note: pop3d should be used only within a secure network;
313otherwise an eavesdropper can steal passwords.
314
315
3165.4. How do I allow selected clients to use this host as a relay? I see
317that qmail-smtpd rejects messages to any host not listed in
318control/rcpthosts. I know I could entirely disable this feature by
319removing control/rcpthosts, but I want to be more selective.
320
321Answer: Three steps. First, install tcp-wrappers, available separately,
322including hosts_options. Second, change your qmail-smtpd line in
323inetd.conf to
324
325 smtp stream tcp nowait qmaild /usr/local/bin/tcpd
326 /var/qmail/bin/tcp-env /var/qmail/bin/qmail-smtpd
327
328(all on one line) and give inetd a HUP. Third, in tcpd's hosts.allow,
329make a line setting the environment variable RELAYCLIENT to the empty
330string for the selected clients:
331
332 tcp-env: 1.2.3.4, 1.2.3.5: setenv = RELAYCLIENT
333
334Here 1.2.3.4 and 1.2.3.5 are the clients' IP addresses. qmail-smtpd
335ignores control/rcpthosts when RELAYCLIENT is set. (It also appends
336RELAYCLIENT to each envelope recipient address. See question 5.5 for an
337application.)
338
339Alternative procedure, if you are using tcpserver: Install tcpcontrol
340(http://pobox.com/~djb/tcpcontrol.html). Create /etc/tcp.smtp containing
341
342 1.2.3.6:allow,RELAYCLIENT=""
343 127.:allow,RELAYCLIENT=""
344
345to allow clients with IP addresses 1.2.3.6 and 127.*. Run
346
347 tcpmakectl /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp
348
349Finally, insert
350
351 tcpcontrol /etc/tcp.smtp.cdb
352
353before /var/qmail/bin/qmail-smtpd in your tcpserver line.
354
355
3565.5. How do I fix up messages from broken SMTP clients?
357
358Answer: Three steps. First, put
359
360 | [ "@$HOST" = "@fixme" ] || ( echo Permission denied; exit 100 )
361 | qmail-inject -f "$SENDER" -- "$EXT2"
362
363into ~alias/.qmail-fixup-default. Second, put
364
365 fixme:fixup
366
367into /var/qmail/control/virtualdomains, and give qmail-send a HUP.
368Third, follow the procedure in question 5.4, but set RELAYCLIENT to the
369string ``@fixme'':
370
371 tcp-env: 1.2.3.6, 1.2.3.7: setenv = RELAYCLIENT @fixme
372
373Here 1.2.3.6 and 1.2.3.7 are the clients' IP addresses. If you are using
374tcpserver and tcpcontrol instead of inetd and tcpd, put
375
376 1.2.3.6:allow,RELAYCLIENT="@fixme"
377 1.2.3.7:allow,RELAYCLIENT="@fixme"
378
379into /etc/tcp.smtp, and run tcpmakectl as in question 5.4.
380
381
382
3836. Configuring MUAs to work with qmail
384
385
3866.1. How do I make BSD mail generate a Date with the local time zone?
387When I send mail, I'd rather use the local time zone than GMT, since
388some MUAs don't know how to display Date in the receiver's time zone.
389
390Answer: Put
391
392 set sendmail=/var/qmail/bin/datemail
393
394into your .mailrc or your system-wide Mail.rc. Beware that BSD mail is
395neither secure nor reliable.
396
397
3986.2. How do I stop pine from crashing? When I ask any version of pine
399past 3.91 to send mail, it crashes.
400
401Answer: Put
402
403 sendmail-path=/usr/lib/sendmail -oem -oi -t
404
405into /usr/local/lib/pine.conf. (This will work with sendmail too.)
406Beware that pine is neither secure nor reliable.
407
408
4096.3. How do I make MH work with qmail?
410
411Answer: Put
412
413 postproc: /usr/mh/lib/spost
414
415into each user's .mh_profile. (This will work with sendmail too.) Beware
416that MH is neither secure nor reliable.
417
418
4196.4. How do I stop Sun's dtcm from hanging?
420
421Answer: There is a novice programming error in dtcm, known as ``failure
422to close the output side of the pipe in the child.'' Sun has, at the
423time of this writing, not yet provided a patch. Sorry.
424
425
426
4277. Managing the mail system
428
429
4307.1. How do I safely stop qmail-send? Back when we were running
431sendmail, it was always tricky to kill sendmail without risking the loss
432of current deliveries; what should I do with qmail-send?
433
434Answer: Go ahead and kill the qmail-send process. It will shut down
435cleanly. Wait for ``exiting'' to show up in the log. To restart it, run
436qmail-start the same way as it's run from your system boot scripts.
437
438
4397.2. How do I manually run the queue? I'd like qmail to try delivering
440all the remote messages right now.
441
442Answer: Give the qmail-send process an ALRM.
443
444
4457.3. How do I rejuvenate a message? Somebody broke into Eric's computer
446again; it's going to be down for at least another two days. I know Eric
447has been expecting an important message---in fact, I see it sitting here
448in /var/qmail/queue/mess/15/26902. It's been in the queue for six days;
449how can I make sure it isn't bounced tomorrow?
450
451Answer: Just touch /var/qmail/queue/info/15/26902. (This is the only
452form of queue modification that's safe while qmail is running.)
453
454
4557.4. How do I organize a big network? I have a lot of machines, and I
456don't know where to start.
457
458Answer: First, choose the domain name where your users will receive
459mail. This is normally the shortest domain name you control. If you are
460in charge of *.movie.edu, you can use addresses like joe@movie.edu.
461
462Second, choose the machine that will know what to do with different
463users at movie.edu. Set up a host name in DNS for this machine:
464
465 mailhost.movie.edu IN A 1.2.3.4
466 4.3.2.1.in-addr.arpa IN PTR mailhost.movie.edu
467
468Here 1.2.3.4 is the IP address of that machine.
469
470Third, make a list of machines where mail should end up. For example, if
471mail for Bob should end up on Bob's workstation, put Bob's workstation
472onto the list. For each of these machines, set up a host name in DNS:
473
474 bobshost.movie.edu IN A 1.2.3.7
475 7.3.2.1.in-addr.arpa IN PTR bobshost.movie.edu
476
477Fourth, install qmail on bobshost.movie.edu. qmail will automatically
478configure itself to accept messages for bob@bobshost.movie.edu and
479deliver them to ~bob/Mailbox on bobshost. Do the same for the other
480machines where mail should end up.
481
482Fifth, install qmail on mailhost.movie.edu. Put
483
484 movie.edu:alias-movie
485
486into control/virtualdomains on mailhost. Then forward bob@movie.edu to
487bob@bobshost.movie.edu, by putting
488
489 bob@bobshost.movie.edu
490
491into ~alias/.qmail-movie-bob. Do the same for other users.
492
493Sixth, put movie.edu into control/rcpthosts on mailhost.movie.edu, so
494that mailhost.movie.edu will accept messages for users at movie.edu.
495
496Seventh, set up an MX record in DNS to deliver movie.edu messages to
497mailhost:
498
499 movie.edu IN MX 10 mailhost.movie.edu
500
501Eighth, on all your machines, put movie.edu into control/defaulthost.
502
503
5047.5. How do I back up and restore the queue disk?
505
506Answer: You can't.
507
508One difficulty is that you can't get a consistent snapshot of the queue
509while qmail-send is running. Another difficulty is that messages in the
510queue must have filenames that match their inode numbers.
511
512However, the big problem is that backups---even twice-daily backups---
513are far too unreliable for mail. If your disk dies, there will be very
514little overlap between the messages saved in the last backup and the
515messages that were lost.
516
517There are several ways to add real reliability to a mail server. Battery
518backups will keep your server alive, letting you park the disk to avoid
519a head crash, when the power goes out. Solid-state disks have their own
520battery backups. RAID boxes let you replace dead disks without losing
521any data.
522
523
524
5258. Miscellany
526
527
5288.1. How do I tell qmail to do more deliveries at once? It's running
529only 20 parallel qmail-remote processes.
530
531Answer: Decide how many deliveries you want to allow at once. Put that
532number into control/concurrencyremote. Restart qmail-send as in question
5337.1. If your system has resource limits, make sure you set the
534descriptors limit to at least double the concurrency plus 5; otherwise
535you'll get lots of unnecessary deferrals whenever a big burst of mail
536shows up. Note that qmail also imposes a compile-time concurrency limit,
537120 by default; this is set in conf-spawn.
538
539
5408.2. How do I keep a copy of all incoming and outgoing mail messages?
541
542Answer: Set QUEUE_EXTRA to "Tlog\0" and QUEUE_EXTRALEN to 5 in extra.h.
543Recompile qmail. Put ./msg-log into ~alias/.qmail-log.
544
545You can also use QUEUE_EXTRA to, e.g., record the Message-ID of every
546message: run
547
548 | awk '/^$/ { exit } /^[mM][eE][sS][sS][aA][gG][eE]-/ { print }'
549
550from ~alias/.qmail-log.
551
552
5538.3. How do I switch slowly from sendmail to qmail? I'm thinking of
554moving the heaven.af.mil network over to qmail, but first I'd like to
555give my users a chance to try out qmail without affecting current
556sendmail deliveries. We're using NFS.
557
558Answer: Find a host in your network, say pc.heaven.af.mil, that isn't
559running an SMTP server. (If addresses at pc.heaven.af.mil are used, you
560should already have an MX pointing pc.heaven.af.mil to your mail hub.)
561
562Set up a new MX record pointing lists.heaven.af.mil to pc.heaven.af.mil.
563Install qmail on pc.heaven.af.mil. Replace pc with lists in the control
564files. Make the qmail man pages available on all your machines.
565
566Now tell your users about qmail. A user can forward joe@heaven.af.mil to
567joe@lists.heaven.af.mil to get ~/Mailbox delivery; he can set up .qmail
568files; he can start running his own mailing lists @lists.heaven.af.mil.
569
570When you're ready to turn sendmail off, you can set up pc.heaven.af.mil
571as your new mail hub. Add heaven.af.mil to control/locals, and change
572the heaven.af.mil MX to point to pc.heaven.af.mil. Make sure you leave
573lists.heaven.af.mil in control/locals so that transition addresses will
574continue to work.