INSTALL.html revision 1.5 1 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3
4 <html>
5
6 <head>
7
8 <title>Postfix Installation From Source Code </title>
9
10 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
11
12 </head>
13
14 <body>
15
16 <h1><img src="postfix-logo.jpg" width="203" height="98" ALT="">Postfix
17 Installation From Source Code </h1>
18
19 <hr>
20
21 <h2> <a name="1">1 - Purpose of this document</a> </h2>
22
23 <p> If you are using a pre-compiled version of Postfix, you should
24 start with BASIC_CONFIGURATION_README and the general documentation
25 referenced by it. INSTALL is only a bootstrap document to get
26 Postfix up and running from scratch with the minimal number of
27 steps; it should not be considered part of the general documentation.
28 </p>
29
30 <p> This document describes how to build, install and configure a
31 Postfix system so that it can do one of the following: </p>
32
33 <ul>
34
35 <li> Send mail only, without changing an existing Sendmail
36 installation.
37
38 <li> Send and receive mail via a virtual host interface, still
39 without any change to an existing Sendmail installation.
40
41 <li> Run Postfix instead of Sendmail.
42
43 </ul>
44
45 <p> Topics covered in this document: </p>
46
47 <ol>
48
49 <li> <a href="#1">Purpose of this document</a>
50
51 <li> <a href="#2">Typographical conventions</a>
52
53 <li> <a href="#3">Documentation</a>
54
55 <li> <a href="#4">Building on a supported system</a>
56
57 <li> <a href="#5">Porting Postfix to an unsupported system</a>
58
59 <li> <a href="#install">Installing the software after successful
60 compilation </a>
61
62 <li> <a href="#send_only">Configuring Postfix to send mail
63 only </a>
64
65 <li> <a href="#send_receive">Configuring Postfix to send and
66 receive mail via virtual interface </a>
67
68 <li> <a href="#replace">Running Postfix instead of Sendmail</a>
69
70 <li> <a href="#mandatory">Mandatory configuration file edits</a>
71
72 <li> <a href="#hamlet">To chroot or not to chroot</a>
73
74 <li> <a href="#care">Care and feeding of the Postfix system</a>
75
76 </ol>
77
78 <h2> <a name="2">2 - Typographical conventions</a> </h2>
79
80 <p> In the instructions below, a command written as </p>
81
82 <blockquote>
83 <pre>
84 # command
85 </pre>
86 </blockquote>
87
88 <p> should be executed as the superuser. </p>
89
90 <p> A command written as </p>
91
92 <blockquote>
93 <pre>
94 $ command
95 </pre>
96 </blockquote>
97
98 <p> should be executed as an unprivileged user. </p>
99
100 <h2> <a name="3">3 - Documentation</a> </h2>
101
102 <p> Documentation is available as README files (start with the file
103 README_FILES/AAAREADME), as HTML web pages (point your browser to
104 "html/index.html") and as UNIX-style manual pages. </p>
105
106 <p> You should view the README files with a pager such as more(1)
107 or less(1), because the files use backspace characters in order to
108 produce <b>bold</b> font. To print a README file without backspace
109 characters, use the col(1) command. For example: </p>
110
111 <blockquote>
112 <pre>
113 $ col -bx <file | lpr
114 </pre>
115 </blockquote>
116
117 <p> In order to view the manual pages before installing Postfix,
118 point your MANPATH environment variable to the "man" subdirectory;
119 be sure to use an absolute path. </p>
120
121 <blockquote>
122 <pre>
123 $ export MANPATH; MANPATH="`pwd`/man:$MANPATH"
124 $ setenv MANPATH "`pwd`/man:$MANPATH"
125 </pre>
126 </blockquote>
127
128 <p> Of particular interest is the postconf(5) manual page that
129 lists all the 500+ configuration parameters. The HTML version of
130 this text makes it easy to navigate around. </p>
131
132 <p> All Postfix source files have their own built-in manual page.
133 Tools to extract those embedded manual pages are available in the
134 mantools directory. </p>
135
136 <h2> <a name="4">4 - Building on a supported system</a> </h2>
137
138 <p> At some point in time, a version of Postfix was supported on: </p>
139
140 <blockquote>
141 <p>
142 AIX 3.2.5, 4.1.x, 4.2.0, 4.3.x, 5.2 <br>
143 BSD/OS 2.x, 3.x, 4.x <br>
144 FreeBSD 2.x .. 9.x <br>
145 HP-UX 9.x, 10.x, 11.x <br>
146 IRIX 5.x, 6.x <br>
147 Linux Debian 1.3.1 and later <br>
148 Linux RedHat 3.x (January 2004) and later <br>
149 Linux Slackware 3.x and later <br>
150 Linux SuSE 5.x and later <br>
151 Linux Ubuntu 4.10 and later<br>
152 Mac OS X <br>
153 NEXTSTEP 3.x <br>
154 NetBSD 1.x and later <br>
155 OPENSTEP 4.x <br>
156 OSF1.V3 - OSF1.V5 (Digital UNIX) <br>
157 Reliant UNIX 5.x <br>
158 SunOS 4.1.4 (March 2007) <br>
159 SunOS 5.4 - 5.10 (Solaris 2.4..10) <br>
160 Ultrix 4.x (well, that was long ago) <br>
161 </p>
162 </blockquote>
163
164 <p> or something closely resemblant. </p>
165
166 <h3>4.1 - Getting started</h3>
167
168 <p> On Solaris, the "make" command and other utilities for software
169 development are in /usr/ccs/bin, so you MUST have /usr/ccs/bin in
170 your command search path. If these files do not exist, install the
171 development packages first. See the Solaris FAQ item "<a
172 href="http://www.science.uva.nl/pub/solaris/solaris2.html#q6.2">Which
173 packages do I need to install to support a C compiler?</a>". </p>
174
175 <p> If you need to build Postfix for multiple architectures, use the
176 "lndir" command to build a shadow tree with symbolic links to the
177 source files. "lndir" is part of X11R6. </p>
178
179 <p> If at any time in the build process you get messages like: "make:
180 don't know how to ..." you should be able to recover by running
181 the following command from the Postfix top-level directory: </p>
182
183 <blockquote>
184 <pre>
185 $ make -f Makefile.init makefiles
186 </pre>
187 </blockquote>
188
189 <p> If you copied the Postfix source code after building it on another
190 machine, it is a good idea to cd into the top-level directory and
191 first do this:</p>
192
193 <blockquote>
194 <pre>
195 $ make tidy
196 </pre>
197 </blockquote>
198
199 <p> This will get rid of any system dependencies left over from
200 compiling the software elsewhere. </p>
201
202 <h3>4.2 - What compiler to use</h3>
203
204 <p> To build with GCC, or with the native compiler if people told me
205 that is better for your system, just cd into the top-level Postfix
206 directory of the source tree and type: </p>
207
208 <blockquote>
209 <pre>
210 $ make
211 </pre>
212 </blockquote>
213
214 <p> To build with a non-default compiler, you need to specify the name
215 of the compiler. Here are a few examples: </p>
216
217 <blockquote>
218 <pre>
219 $ make makefiles CC=/opt/SUNWspro/bin/cc (Solaris)
220 $ make
221
222 $ make makefiles CC="/opt/ansic/bin/cc -Ae" (HP-UX)
223 $ make
224
225 $ make makefiles CC="purify cc"
226 $ make
227 </pre>
228 </blockquote>
229
230 <p> and so on. In some cases, optimization is turned off automatically. </p>
231
232 <h3>4.3 - Building with optional extensions</h3>
233
234 By default, Postfix builds as a mail system with relatively few
235 bells and whistles. Support for third-party databases etc.
236 must be configured when Postfix is compiled. The following documents describe how to build Postfix with support for extensions:
237
238 <blockquote>
239 <table border="1">
240
241 <tr> <th>Postfix extension </th> <th>Document </th> <th>Availability</th>
242 </tr>
243
244 <tr> <td> Berkeley DB database</td> <td>DB_README</td> <td> Postfix
245 1.0 </td> </tr>
246
247 <tr> <td> LDAP database</td> <td>LDAP_README</td> <td> Postfix
248 1.0 </td> </tr>
249
250 <tr> <td> MySQL database</td> <td>MYSQL_README</td> <td> Postfix
251 1.0 </td> </tr>
252
253 <tr> <td> Perl compatible regular expression</td> <td>PCRE_README</td>
254 <td> Postfix 1.0 </td> </tr>
255
256 <tr> <td> PostgreSQL database</td> <td>PGSQL_README</td> <td>
257 Postfix 2.0 </td> </tr>
258
259 <tr> <td> SASL authentication </td> <td>SASL_README</td> <td>
260 Postfix 1.0 </td> </tr>
261
262 <tr> <td> SQLite database</td> <td>SQLITE_README</td> <td> Postfix
263 2.8 </td> </tr>
264
265 <tr> <td> STARTTLS session encryption </td> <td>TLS_README</td> <td>
266 Postfix 2.2 </td> </tr>
267
268 </table>
269
270 </blockquote>
271
272 <p> Note: IP version 6 support is compiled into Postfix on operating
273 systems that have IPv6 support. See the IPV6_README file for details.
274 </p>
275
276 <h3>4.4 - Overriding built-in parameter default settings</h3>
277
278 <p> All Postfix configuration parameters can be changed by editing
279 a Postfix configuration file, except for one: the parameter that
280 specifies the location of Postfix configuration files. In order to
281 build Postfix with a configuration directory other than /etc/postfix,
282 use: </p>
283
284 <blockquote>
285 <pre>
286 $ make makefiles CCARGS='-DDEF_CONFIG_DIR=\"/some/where\"'
287 $ make
288 </pre>
289 </blockquote>
290
291 <p> IMPORTANT: Be sure to get the quotes right. These details matter
292 a lot. </p>
293
294 <p> Parameters whose defaults can be specified in this way are: </p>
295
296 <blockquote>
297
298 <table border="1">
299
300 <tr><th> Macro name </th> <th>default value for</th> <th>typical
301 default</th> </tr>
302
303 <tr> <td>DEF_COMMAND_DIR</td> <td>command_directory</td>
304 <td>/usr/sbin</td> </tr>
305
306 <tr> <td>DEF_CONFIG_DIR</td> <td>config_directory</td>
307 <td>/etc/postfix</td> </tr>
308
309 <tr> <td>DEF_DAEMON_DIR</td> <td>daemon_directory</td>
310 <td>/usr/libexec/postfix</td> </tr>
311
312 <tr> <td>DEF_DATA_DIR</td> <td>data_directory</td>
313 <td>/var/db/postfix</td> </tr>
314
315 <tr> <td>DEF_MAILQ_PATH</td> <td>mailq_path</td> <td>/usr/bin/mailq</td>
316 </tr>
317
318 <tr> <td>DEF_HTML_DIR</td> <td>html_directory</td>
319 <td>no</td> </tr>
320
321 <tr> <td>DEF_MANPAGE_DIR</td> <td>manpage_directory</td>
322 <td>/usr/local/man</td> </tr>
323
324 <tr> <td>DEF_NEWALIAS_PATH</td> <td>newaliases_path</td>
325 <td>/usr/bin/newaliases</td> </tr>
326
327 <tr> <td>DEF_QUEUE_DIR</td> <td>queue_directory</td>
328 <td>/var/spool/postfix</td> </tr>
329
330 <tr> <td>DEF_README_DIR</td> <td>readme_directory</td>
331 <td>no</td> </tr>
332
333 <tr> <td>DEF_SENDMAIL_PATH</td> <td>sendmail_path</td>
334 <td>/usr/sbin/sendmail</td> </tr>
335
336 </table>
337
338 </blockquote>
339
340 <p> Note: the data_directory parameter (for caches and pseudo-random
341 numbers) was introduced with Postfix version 2.5. </p>
342
343 <h3>4.5 - Overriding other compile-time features</h3>
344
345 <p> The general method to override Postfix compile-time features
346 is as follows: </p>
347
348 <blockquote>
349 <pre>
350 $ make makefiles name=value name=value...
351 $ make
352 </pre>
353 </blockquote>
354
355 <p> The following is an extensive list of names and values. </p>
356
357 <table border="1">
358
359 <tr> <th colspan="2"> Name/Value </th> <th> Description </th> </tr>
360
361 <tr> <td colspan="2"> AUXLIBS="object_library..."</td> <td> Specifies
362 one or more non-default object libraries. </td> </tr>
363
364 <tr> <td colspan="2"> CC=compiler_command</td> <td> Specifies a
365 non-default compiler. On many systems, the default is <tt>gcc</tt>.
366 </td> </tr>
367
368 <tr> <td colspan="2"> CCARGS="compiler_arguments..."</td> <td>
369 Specifies non-default compiler arguments, for example, a non-default
370 <tt>include</tt> directory. The following directives turn
371 off Postfix features at compile time:</td> </tr>
372
373 <tr> <td> </td> <td> -DNO_DB </td> <td> Do not build with Berkeley
374 DB support. By default, Berkeley DB support is compiled in on
375 platforms that are known to support this feature. </td> </tr>
376
377 <tr> <td> </td> <td> -DNO_DEVPOLL </td> <td> Do not build with
378 Solaris <tt>/dev/poll</tt> support. By default, <tt>/dev/poll</tt>
379 support is compiled in on Solaris versions that are known to support
380 this feature. </td> </tr>
381
382 <tr> <td> </td> <td> -DNO_EPOLL </td> <td> Do not build with Linux
383 EPOLL support. By default, EPOLL support is compiled in on platforms
384 that are known to support this feature. </td> </tr>
385
386 <tr> <td> </td> <td> -DNO_IPV6 </td> <td> Do not build with IPv6
387 support. By default, IPv6 support is compiled in on platforms that
388 are known to have IPv6 support. Note: this directive is for debugging
389 and testing only. It is not guaranteed to work on all platforms.
390 </td> </tr>
391
392 <tr> <td> </td> <td> -DNO_KQUEUE </td> <td> Do not build with FreeBSD
393 / NetBSD / OpenBSD / MacOSX KQUEUE support. By default, KQUEUE
394 support is compiled in on platforms that are known to support it.
395 </td> </tr>
396
397 <tr> <td> </td> <td> -DNO_NIS </td> <td> Do not build with NIS or
398 NISPLUS support. NIS is not available on some recent Linux or Solaris
399 distributions. </td> </tr>
400
401 <tr> <td> </td> <td> -DNO_PCRE </td> <td> Do not build with PCRE
402 support. By default, PCRE support is compiled in when the
403 <tt>pcre-config</tt> utility is installed. </td> </tr>
404
405 <tr> <td> </td> <td> -DNO_POSIX_GETPW_R </td> <td> Disable support
406 for POSIX <tt>getpwnam_r/getpwuid_r</tt>. By default Postfix uses
407 these where they are known to be available. </td> </tr>
408
409 <tr> <td> </td> <td> -DNO_SIGSETJMP </td> <td> Use
410 <tt>setjmp()/longjmp()</tt> instead of <tt>sigsetjmp()/siglongjmp()</tt>.
411 By default, Postfix uses <tt>sigsetjmp()/siglongjmp()</tt> when
412 they are known to be available. </td> </tr>
413
414 <tr> <td colspan="2"> DEBUG=debug_level </td> <td> Specifies a
415 non-default compiler debugging level. The default is <tt>-g</tt>.
416 Specify DEBUG= to turn off debugging. </td> </tr>
417
418 <tr> <td colspan="2"> OPT=optimization_level </td> <td> Specifies
419 a non-default optimization level. The default is -O. Specify OPT=
420 to turn off optimization. </td> </tr>
421
422 <tr> <td colspan="2"> WARN="warning_flags..." </td> <td> Specifies
423 non-default <tt>gcc</tt> compiler warning options for use when
424 "<tt>make</tt>" is invoked in a source subdirectory only. </td>
425 </tr>
426
427 </table>
428
429 <h3>4.6 - Support for thousands of processes</h3>
430
431 <p> The number of connections that Postfix can manage simultaneously
432 is limited by the number of processes that it can run. This number
433 in turn is limited by the number of files and sockets that a single
434 process can open. For example, the Postfix queue manager has a
435 separate connection to each delivery process, and the anvil(8)
436 server has one connection per smtpd(8) process. </p>
437
438 <p> Postfix version 2.4 and later have no built-in limits on the
439 number of open files or sockets, when compiled on systems that
440 support one of the following: </p>
441
442 <ul>
443
444 <li> BSD kqueue(2) (FreeBSD 4.1, NetBSD 2.0, OpenBSD 2.9),
445
446 <li> Solaris 8 /dev/poll,
447
448 <li> Linux 2.6 epoll(4).
449
450 </ul>
451
452
453 <p> With other Postfix versions or operating systems, the number
454 of file descriptors per process is limited by the value of the
455 FD_SETSIZE macro. If you expect to run more than 1000 mail delivery
456 processes, you may need to override the definition of the FD_SETSIZE
457 macro to make select() work correctly: </p>
458
459 <blockquote>
460 <pre>
461 $ make makefiles CCARGS=-DFD_SETSIZE=2048
462 </pre>
463 </blockquote>
464
465 <p> Warning: the above has no effect on some Linux versions.
466 Apparently, on these systems the FD_SETSIZE value can be changed
467 only by using undocumented interfaces. Currently, that means
468 including <bits/types.h> directly (which is not allowed) and
469 overriding the __FD_SETSIZE macro. Beware, undocumented interfaces
470 can change at any time and without warning. </p>
471
472 <p> But wait, there is more: none of this will work unless the
473 operating system is configured to handle thousands of connections.
474 See the TUNING_README guide for examples of how to increase the
475 number of open sockets or files. </p>
476
477 <h3>4.7 - Compiling Postfix, at last</h3>
478
479 <p> If the command </p>
480
481 <blockquote>
482 <pre>
483 $ make
484 </pre>
485 </blockquote>
486
487 <p> is successful, then you can proceed to <a href="#install">install</a>
488 Postfix (section 6).
489
490 <p> If the command produces compiler error messages, it may be time
491 to search the web or to ask the postfix-users (a] postfix.org mailing
492 list, but be sure to search the mailing list archives first. Some
493 mailing list archives are linked from http://www.postfix.org/. </p>
494
495 <h2> <a name="5">5 - Porting Postfix to an unsupported system</a> </h2>
496
497 <p> Each system type that Postfix knows is identified by a unique
498 name. Examples: SUNOS5, FREEBSD4, and so on. When porting Postfix
499 to a new system, the first step is to choose a SYSTEMTYPE name for
500 the new system. You must use a name that includes at least the
501 major version of the operating system (such as SUNOS4 or LINUX2),
502 so that different releases of the same system can be supported
503 without confusion. </p>
504
505 <p> Add a case statement to the "makedefs" shell script in the
506 source code top-level directory that recognizes the new system
507 reliably, and that emits the right system-specific information.
508 Be sure to make the code robust against user PATH settings; if the
509 system offers multiple UNIX flavors (e.g. BSD and SYSV) be sure to
510 build for the native flavor, instead of the emulated one. </p>
511
512 <p> Add an "#ifdef SYSTEMTYPE" section to the central util/sys_defs.h
513 include file. You may have to invent new feature macro names.
514 Please choose sensible feature macro names such as HAS_DBM or
515 FIONREAD_IN_SYS_FILIO_H.
516
517 <p> I strongly recommend against using "#ifdef SYSTEMTYPE" in
518 individual source files. While this may look like the quickest
519 solution, it will create a mess when newer versions of the same
520 SYSTEMTYPE need to be supported. You're likely to end up placing
521 "#ifdef" sections all over the source code again. </p>
522
523 <h2><a name="install">6 - Installing the software after successful
524 compilation</a></h2>
525
526 <p> This text describes how to install Postfix from source code.
527 See the PACKAGE_README file if you are building a package for
528 distribution to other systems. </p>
529
530 <h3>6.1 - Save existing Sendmail binaries</h3>
531
532 <p> <a name="save">IMPORTANT</a>: if you are REPLACING an existing
533 Sendmail installation with Postfix, you may need to keep the old
534 sendmail program running for some time in order to flush the mail
535 queue. </p>
536
537 <ul>
538
539 <li> <p> Some systems implement a mail switch mechanism where
540 different MTAs (Postfix, Sendmail, etc.) can be installed at the
541 same time, while only one of them is actually being used. Examples
542 of such switching mechanisms are the FreeBSD mailwrapper(8) or the
543 Linux mail switch. In this case you should try to "flip" the switch
544 to "Postfix" before installing Postfix. </p>
545
546 <li> <p> If your system has no mail switch mechanism, execute the
547 following commands (your sendmail, newaliases and mailq programs
548 may be in a different place): </p>
549
550 <pre>
551 # mv /usr/sbin/sendmail /usr/sbin/sendmail.OFF
552 # mv /usr/bin/newaliases /usr/bin/newaliases.OFF
553 # mv /usr/bin/mailq /usr/bin/mailq.OFF
554 # chmod 755 /usr/sbin/sendmail.OFF /usr/bin/newaliases.OFF \
555 /usr/bin/mailq.OFF
556 </pre>
557
558 </ul>
559
560 <h3>6.2 - Create account and groups</h3>
561
562 <p> Before you install Postfix for the first time you need to
563 create an account and a group:</p>
564
565 <ul>
566
567 <li> <p> Create a user account "postfix" with a user id and group
568 id that are not used by any other user account. Preferably, this
569 is an account that no-one can log into. The account does not need
570 an executable login shell, and needs no existing home directory.
571 My password and group file entries look like this: </p>
572
573 <blockquote>
574 <pre>
575 /etc/passwd:
576 postfix:*:12345:12345:postfix:/no/where:/no/shell
577
578 /etc/group:
579 postfix:*:12345:
580 </pre>
581 </blockquote>
582
583 <p> Note: there should be no whitespace before "postfix:". </p>
584
585 <li> <p> Create a group "postdrop" with a group id that is not used
586 by any other user account. Not even by the postfix user account.
587 My group file entry looks like:
588
589 <blockquote>
590 <pre>
591 /etc/group:
592 postdrop:*:54321:
593 </pre>
594 </blockquote>
595
596 <p> Note: there should be no whitespace before "postdrop:". </p>
597
598 </ul>
599
600 <h3>6.3 - Install Postfix</h3>
601
602 <p> To install or upgrade Postfix from compiled source code, run
603 one of the following commands as the super-user:</p>
604
605 <blockquote>
606 <pre>
607 # make install (interactive version, first time install)
608
609 # make upgrade (non-interactive version, for upgrades)
610 </pre>
611 </blockquote>
612
613 <ul>
614
615 <li> <p> The interactive version ("make install") asks for pathnames
616 for Postfix data and program files, and stores your preferences in
617 the main.cf file. <b> If you don't want Postfix to overwrite
618 non-Postfix "sendmail", "mailq" and "newaliases" files, specify
619 pathnames that end in ".postfix"</b>. </p>
620
621 <li> <p> The non-interactive version ("make upgrade") needs the
622 /etc/postfix/main.cf file from a previous installation. If the file
623 does not exist, use interactive installation ("make install")
624 instead. </p>
625
626 </ul>
627
628 <h3>6.4 - Configure Postfix</h3>
629
630 <p> Proceed to the section on how you wish to run Postfix on
631 your particular machine: </p>
632
633 <ul>
634
635 <li> <p> <a href="#send_only">Send</a> mail only, without changing
636 an existing Sendmail installation (section 7). </p>
637
638 <li> <p> <a href="#send_receive">Send and receive</a> mail via a
639 virtual host interface, still without any change to an existing
640 Sendmail installation (section 8). </p>
641
642 <li> <p> Run Postfix <a href="#replace">instead of</a> Sendmail
643 (section 9). </p>
644
645 </ul>
646
647 <h2><a name="send_only">7 - Configuring Postfix to send mail
648 only</a></h2>
649
650 <p> If you are going to use Postfix to send mail only, there is no
651 need to change your existing sendmail setup. Instead, set up your
652 mail user agent so that it calls the Postfix sendmail program
653 directly. </p>
654
655 <p> Follow the instructions in the "<a href="#mandatory">Mandatory
656 configuration file edits</a>" in section 10, and review the "<a
657 href="#hamlet">To chroot or not to chroot</a>" text in section
658 11. </p>
659
660 <p> You MUST comment out the "smtp inet" entry in /etc/postfix/master.cf,
661 in order to avoid conflicts with the real sendmail. Put a "#"
662 character in front of the line that defines the smtpd service: </p>
663
664 <blockquote>
665 <pre>
666 /etc/postfix/master.cf:
667 #smtp inet n - n - - smtpd
668 </pre>
669 </blockquote>
670
671 <p> Start the Postfix system: </p>
672
673 <blockquote>
674 <pre>
675 # postfix start
676 </pre>
677 </blockquote>
678
679 <p> or, if you feel nostalgic, use the Postfix sendmail command: </p>
680
681 <blockquote>
682 <pre>
683 # sendmail -bd -qwhatever
684 </pre>
685 </blockquote>
686
687 <p> and watch your maillog file for any error messages. The pathname
688 is /var/log/maillog, /var/log/mail, /var/log/syslog, or something
689 else. Typically, the pathname is defined in the /etc/syslog.conf
690 file. </p>
691
692 <blockquote>
693 <pre>
694 $ egrep '(reject|warning|error|fatal|panic):' /some/log/file
695 </pre>
696 </blockquote>
697
698 <p> Note: the most important error message is logged first. Later
699 messages are not as useful. </p>
700
701 <p> In order to inspect the mail queue, use one of the following
702 commands: </p>
703
704 <blockquote>
705 <pre>
706 $ mailq
707
708 $ sendmail -bp
709
710 $ postqueue -p
711 </pre>
712 </blockquote>
713
714 <p> See also the "<a href="#care">Care and feeding</a>" section 12
715 below. </p>
716
717 <h2><a name="send_receive">8 - Configuring Postfix to send and
718 receive mail via virtual interface</a></h2>
719
720 <p> Alternatively, you can use the Postfix system to send AND
721 receive mail while leaving your Sendmail setup intact, by running
722 Postfix on a virtual interface address. Simply configure your mail
723 user agent to directly invoke the Postfix sendmail program. </p>
724
725 <p> To create a virtual network interface address, study your
726 system ifconfig manual page. The command syntax could be any
727 of: </p>
728
729 <blockquote>
730 <pre>
731 # <b>ifconfig le0:1 <address> netmask <mask> up</b>
732 # <b>ifconfig en0 alias <address> netmask 255.255.255.255</b>
733 </pre>
734 </blockquote>
735
736 <p> In the /etc/postfix/main.cf file, I would specify </p>
737
738 <blockquote>
739 <pre>
740 /etc/postfix/main.cf:
741 myhostname = virtual.host.tld
742 inet_interfaces = $myhostname
743 mydestination = $myhostname
744 </pre>
745 </blockquote>
746
747 <p> Follow the instructions in the "<a href="#mandatory">Mandatory
748 configuration file edits</a>" in section 10, and review the "<a
749 name="#hamlet">To chroot or not to chroot</a>" text in section
750 11. </p>
751
752 <p> Start the Postfix system: </p>
753
754 <blockquote>
755 <pre>
756 # postfix start
757 </pre>
758 </blockquote>
759
760 <p> or, if you feel nostalgic, use the Postfix sendmail command: </p>
761
762 <blockquote>
763 <pre>
764 # sendmail -bd -qwhatever
765 </pre>
766 </blockquote>
767
768 <p> and watch your maillog file for any error messages. The pathname
769 is /var/log/maillog, /var/log/mail, /var/log/syslog, or something
770 else. Typically, the pathname is defined in the /etc/syslog.conf
771 file. </p>
772
773 <blockquote>
774 <pre>
775 $ egrep '(reject|warning|error|fatal|panic):' /some/log/file
776 </pre>
777 </blockquote>
778
779 <p> Note: the most important error message is logged first. Later
780 messages are not as useful. </p>
781
782 <p> In order to inspect the mail queue, use one of the following
783 commands: </p>
784
785 <blockquote>
786 <pre>
787 $ mailq
788
789 $ sendmail -bp
790
791 $ postqueue -p
792 </pre>
793 </blockquote>
794
795 <p> See also the "<a href="#care">Care and feeding</a>" section 12
796 below. </p>
797
798 <h2><a name="replace">9 - Running Postfix instead of Sendmail</a></h2>
799
800 <p> Prior to installing Postfix you should <a href="#save">save</a>
801 any existing sendmail program files as described in section 6. Be
802 sure to keep the old sendmail running for at least a couple days
803 to flush any unsent mail. To do so, stop the sendmail daemon and
804 restart it as: </p>
805
806 <blockquote>
807 <pre>
808 # /usr/sbin/sendmail.OFF -q
809 </pre>
810 </blockquote>
811
812 <p> Note: this is old sendmail syntax. Newer versions use separate
813 processes for mail submission and for running the queue. </p>
814
815 <p> After you have visited the "<a href="#mandatory">Mandatory
816 configuration file edits</a>" section below, you can start the
817 Postfix system with: </p>
818
819 <blockquote>
820 <pre>
821 # postfix start
822 </pre>
823 </blockquote>
824
825 <p> or, if you feel nostalgic, use the Postfix sendmail command: </p>
826
827 <blockquote>
828 <pre>
829 # sendmail -bd -qwhatever
830 </pre>
831 </blockquote>
832
833 <p> and watch your maillog file for any error messages. The pathname
834 is /var/log/maillog, /var/log/mail, /var/log/syslog, or something
835 else. Typically, the pathname is defined in the /etc/syslog.conf
836 file. </p>
837
838 <blockquote>
839 <pre>
840 $ egrep '(reject|warning|error|fatal|panic):' /some/log/file
841 </pre>
842 </blockquote>
843
844 <p> Note: the most important error message is logged first. Later
845 messages are not as useful. </p>
846
847 <p> In order to inspect the mail queue, use one of the following
848 commands: </p>
849
850 <blockquote>
851 <pre>
852 $ mailq
853
854 $ sendmail -bp
855
856 $ postqueue -p
857 </pre>
858 </blockquote>
859
860 <p> See also the "<a href="#care">Care and feeding</a>" section 12
861 below. </p>
862
863 <h2><a name="mandatory">10 - Mandatory configuration file edits</a></h2>
864
865 <p> Note: the material covered in this section is covered in more
866 detail in the BASIC_CONFIGURATION_README document. The information
867 presented below is targeted at experienced system administrators.
868 </p>
869
870 <h3>10.1 - Postfix configuration files</h3>
871
872 <p> By default, Postfix configuration files are in /etc/postfix.
873 The two most important files are main.cf and master.cf; these files
874 must be owned by root. Giving someone else write permission to
875 main.cf or master.cf (or to their parent directories) means giving
876 root privileges to that person. </p>
877
878 <p> In /etc/postfix/main.cf, you will have to set up a minimal number
879 of configuration parameters. Postfix configuration parameters
880 resemble shell variables, with two important differences: the first
881 one is that Postfix does not know about quotes like the UNIX shell
882 does.</p>
883
884 <p> You specify a configuration parameter as: </p>
885
886 <blockquote>
887 <pre>
888 /etc/postfix/main.cf:
889 parameter = value
890 </pre>
891 </blockquote>
892
893 <p> and you use it by putting a "$" character in front of its name: </p>
894
895 <blockquote>
896 <pre>
897 /etc/postfix/main.cf:
898 other_parameter = $parameter
899 </pre>
900 </blockquote>
901
902 <p> You can use $parameter before it is given a value (that is the
903 second main difference with UNIX shell variables). The Postfix
904 configuration language uses lazy evaluation, and does not look at
905 a parameter value until it is needed at runtime. </p>
906
907 <p> Whenever you make a change to the main.cf or master.cf file,
908 execute the following command in order to refresh a running mail
909 system: </p>
910
911 <blockquote>
912 <pre>
913 # postfix reload
914 </pre>
915 </blockquote>
916
917 <h3>10.2 - Default domain for unqualified addresses</h3>
918
919 <p> First of all, you must specify what domain will be appended to an
920 unqualified address (i.e. an address without @domain.tld). The
921 "myorigin" parameter defaults to the local hostname, but that is
922 probably OK only for very small sites. </p>
923
924 <p> Some examples (use only one): </p>
925
926 <blockquote>
927 <pre>
928 /etc/postfix/main.cf:
929 myorigin = $myhostname (send mail as "user@$myhostname")
930 myorigin = $mydomain (send mail as "user@$mydomain")
931 </pre>
932 </blockquote>
933
934 <h3>10.3 - What domains to receive locally</h3>
935
936 <p> Next you need to specify what mail addresses Postfix should deliver
937 locally. </p>
938
939 <p> Some examples (use only one): </p>
940
941 <blockquote>
942 <pre>
943 /etc/postfix/main.cf:
944 mydestination = $myhostname, localhost.$mydomain, localhost
945 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
946 mydestination = $myhostname
947 </pre>
948 </blockquote>
949
950 <p>The first example is appropriate for a workstation, the second
951 is appropriate for the mailserver for an entire domain. The third
952 example should be used when running on a virtual host interface.</p>
953
954 <h3>10.4 - Proxy/NAT interface addresses </h3>
955
956 <p> The proxy_interfaces parameter specifies all network addresses
957 that Postfix receives mail on by way of a proxy or network address
958 translation unit. You may specify symbolic hostnames instead of
959 network addresses. </p>
960
961 <p> IMPORTANT: You must specify your proxy/NAT external addresses
962 when your system is a backup MX host for other domains, otherwise
963 mail delivery loops will happen when the primary MX host is down.
964 </p>
965
966 <p> Example: host behind NAT box running a backup MX host. </p>
967
968 <blockquote>
969 <pre>
970 /etc/postfix/main.cf:
971 proxy_interfaces = 1.2.3.4 (the proxy/NAT external network address)
972 </pre>
973 </blockquote>
974
975 <h3>10.5 - What local clients to relay mail from </h3>
976
977 <p> If your machine is on an open network then you must specify
978 what client IP addresses are authorized to relay their mail through
979 your machine into the Internet. The default setting includes all
980 subnetworks that the machine is attached to. This may give relay
981 permission to too many clients. My own settings are: </p>
982
983 <blockquote>
984 <pre>
985 /etc/postfix/main.cf:
986 mynetworks = 168.100.189.0/28, 127.0.0.0/8
987 </pre>
988 </blockquote>
989
990 <h3>10.6 - What relay destinations to accept from strangers </h3>
991
992 <p> If your machine is on an open network then you must also specify
993 whether Postfix will forward mail from strangers. The default
994 setting will forward mail to all domains (and subdomains of) what
995 is listed in $mydestination. This may give relay permission for
996 too many destinations. Recommended settings (use only one): </p>
997
998 <blockquote>
999 <pre>
1000 /etc/postfix/main.cf:
1001 relay_domains = (do not forward mail from strangers)
1002 relay_domains = $mydomain (my domain and subdomains)
1003 relay_domains = $mydomain, other.domain.tld, ...
1004 </pre>
1005 </blockquote>
1006
1007 <h3>10.7 - Optional: configure a smart host for remote delivery</h3>
1008
1009 <p> If you're behind a firewall, you should set up a relayhost. If
1010 you can, specify the organizational domain name so that Postfix
1011 can use DNS lookups, and so that it can fall back to a secondary
1012 MX host when the primary MX host is down. Otherwise just specify
1013 a hard-coded hostname. </p>
1014
1015 <p> Some examples (use only one): </p>
1016
1017 <blockquote>
1018 <pre>
1019 /etc/postfix/main.cf:
1020 relayhost = $mydomain
1021 relayhost = [mail.$mydomain]
1022 </pre>
1023 </blockquote>
1024
1025 <p> The form enclosed with <tt>[]</tt> eliminates DNS MX lookups. </p>
1026
1027 <p> By default, the SMTP client will do DNS lookups even when you
1028 specify a relay host. If your machine has no access to a DNS server,
1029 turn off SMTP client DNS lookups like this: </p>
1030
1031 <blockquote>
1032 <pre>
1033 /etc/postfix/main.cf:
1034 disable_dns_lookups = yes
1035 </pre>
1036 </blockquote>
1037
1038 <p> The STANDARD_CONFIGURATION_README file has more hints and tips for
1039 firewalled and/or dial-up networks. </p>
1040
1041 <h3>10.8 - Create the aliases database</h3>
1042
1043 <p> Postfix uses a Sendmail-compatible aliases(5) table to redirect
1044 mail for local(8) recipients. Typically, this information is kept
1045 in two files: in a text file /etc/aliases and in an indexed file
1046 /etc/aliases.db. The command "postconf alias_maps" will tell you
1047 the exact location of the text file. </p>
1048
1049 <p> First, be sure to update the text file with aliases for root,
1050 postmaster and "postfix" that forward mail to a real person. Postfix
1051 has a sample aliases file /etc/postfix/aliases that you can adapt
1052 to local conditions. </p>
1053
1054 <blockquote>
1055 <pre>
1056 /etc/aliases:
1057 root: you
1058 postmaster: root
1059 postfix: root
1060 bin: root
1061 <i>etcetera...</i>
1062 </pre>
1063 </blockquote>
1064
1065 <p> Note: there should be no whitespace before the ":". </p>
1066
1067 <p> Finally, build the indexed aliases file with one of the
1068 following commands: </p>
1069
1070 <blockquote>
1071 <pre>
1072 # newaliases
1073 # sendmail -bi
1074 </pre>
1075 </blockquote>
1076
1077 <h2><a name="hamlet">11 - To chroot or not to chroot</a></h2>
1078
1079 <p> Postfix daemon processes can be configured (via master.cf) to
1080 run in a chroot jail. The processes run at a fixed low privilege
1081 and with access only to the Postfix queue directories (/var/spool/postfix).
1082 This provides a significant barrier against intrusion. The barrier
1083 is not impenetrable, but every little bit helps. </p>
1084
1085 <p> With the exception of Postfix daemons that deliver mail locally
1086 and/or that execute non-Postfix commands, every Postfix daemon can
1087 run chrooted. </p>
1088
1089 <p> Sites with high security requirements should consider to chroot
1090 all daemons that talk to the network: the smtp(8) and smtpd(8)
1091 processes, and perhaps also the lmtp(8) client. The author's own
1092 porcupine.org mail server runs all daemons chrooted that can be
1093 chrooted. </p>
1094
1095 <p> The default /etc/postfix/master.cf file specifies that no
1096 Postfix daemon runs chrooted. In order to enable chroot operation,
1097 edit the file /etc/postfix/master.cf. Instructions are in the file.
1098 </p>
1099
1100 <p> Note that a chrooted daemon resolves all filenames relative to
1101 the Postfix queue directory (/var/spool/postfix). For successful
1102 use of a chroot jail, most UNIX systems require you to bring in
1103 some files or device nodes. The examples/chroot-setup directory
1104 in the source code distribution has a collection of scripts that
1105 help you set up Postfix chroot environments on different operating
1106 systems. </p>
1107
1108 <p> Additionally, you almost certainly need to configure syslogd
1109 so that it listens on a socket inside the Postfix queue directory.
1110 Examples for specific systems: </p>
1111
1112 <dl>
1113
1114 <dt> FreeBSD: </dt>
1115
1116 <dd> <pre>
1117 # mkdir -p /var/spool/postfix/var/run
1118 # syslogd -l /var/spool/postfix/var/run/log
1119 </pre> </dd>
1120
1121 <dt> Linux, OpenBSD: </dt>
1122
1123 <dd> <pre>
1124 # mkdir -p /var/spool/postfix/dev
1125 # syslogd -a /var/spool/postfix/dev/log
1126 </pre> </dd>
1127
1128 </dl>
1129
1130 <h2><a name="care">12 - Care and feeding of the Postfix system</a></h2>
1131
1132 <p> Postfix daemon processes run in the background, and log problems
1133 and normal activity to the syslog daemon. The names of logfiles
1134 are specified in /etc/syslog.conf. At the very least you need
1135 something like: </p>
1136
1137 <blockquote>
1138 <pre>
1139 /etc/syslog.conf:
1140 mail.err /dev/console
1141 mail.debug /var/log/maillog
1142 </pre>
1143 </blockquote>
1144
1145 <p> IMPORTANT: the syslogd will not create files. You must create
1146 them before (re)starting syslogd. </p>
1147
1148 <p> IMPORTANT: on Linux you need to put a "-" character before
1149 the pathname, e.g., -/var/log/maillog, otherwise the syslogd
1150 will use more system resources than Postfix does. </p>
1151
1152 <p> Hopefully, the number of problems will be small, but it is a good
1153 idea to run every night before the syslog files are rotated: </p>
1154
1155 <blockquote>
1156 <pre>
1157 # postfix check
1158 # egrep '(reject|warning|error|fatal|panic):' /some/log/file
1159 </pre>
1160 </blockquote>
1161
1162 <ul>
1163
1164 <li> <p> The first line (postfix check) causes Postfix to report
1165 file permission/ownership discrepancies. </p>
1166
1167 <li> <p> The second line looks for problem reports from the mail
1168 software, and reports how effective the relay and junk mail access
1169 blocks are. This may produce a lot of output. You will want to
1170 apply some postprocessing to eliminate uninteresting information.
1171 </p>
1172
1173 </ul>
1174
1175 <p> The <a href="DEBUG_README.html#logging"> DEBUG_README </a>
1176 document describes the meaning of the "warning" etc. labels in
1177 Postfix logging. </p>
1178
1179 </body>
1180
1181 </html>
1182