xref: /netbsd-src/external/ibm-public/postfix/dist/proto/INSTALL.html (revision d11b170b9000ada93db553723522a63d5deac310)
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
17Installation 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
24start with BASIC_CONFIGURATION_README and the general documentation
25referenced by it.  INSTALL is only a bootstrap document to get
26Postfix up and running from scratch with the minimal number of
27steps; 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
31Postfix 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
36installation.
37
38<li> Send and receive mail via a virtual host interface, still
39without 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
60compilation </a>
61
62<li> <a href="#send_only">Configuring Postfix to send mail
63only </a>
64
65<li> <a href="#send_receive">Configuring Postfix to send and
66receive 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
103README_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)
107or less(1), because the files use backspace characters in order to
108produce <b>bold</b> font. To print a README file without backspace
109characters, use the col(1) command.  For example: </p>
110
111<blockquote>
112<pre>
113$ col -bx &lt;file | lpr
114</pre>
115</blockquote>
116
117<p> In order to view the manual pages before installing Postfix,
118point your MANPATH environment variable to the "man" subdirectory;
119be 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
129lists all the 500+ configuration parameters. The HTML version of
130this text makes it easy to navigate around.  </p>
131
132<p> All Postfix source files have their own built-in manual page.
133Tools to extract those embedded manual pages are available in the
134mantools 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>
142AIX 3.2.5, 4.1.x, 4.2.0, 4.3.x, 5.2 <br>
143BSD/OS 2.x, 3.x, 4.x <br>
144FreeBSD 2.x .. 9.x <br>
145HP-UX  9.x, 10.x, 11.x <br>
146IRIX 5.x, 6.x <br>
147Linux Debian 1.3.1 and later <br>
148Linux RedHat 3.x (January 2004) and later <br>
149Linux Slackware 3.x and later <br>
150Linux SuSE 5.x and later <br>
151Linux Ubuntu 4.10 and later<br>
152Mac OS X <br>
153NEXTSTEP 3.x <br>
154NetBSD 1.x and later <br>
155OPENSTEP 4.x <br>
156OSF1.V3 - OSF1.V5 (Digital UNIX) <br>
157Reliant UNIX 5.x <br>
158SunOS 4.1.4 (March 2007) <br>
159SunOS 5.4 - 5.10 (Solaris 2.4..10) <br>
160Ultrix 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
169development are in /usr/ccs/bin, so you MUST have /usr/ccs/bin in
170your command search path. If these files do not exist, install the
171development packages first. See the Solaris FAQ item "<a
172href="http://www.science.uva.nl/pub/solaris/solaris2.html#q6.2">Which
173packages 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
177source files. "lndir" is part of X11R6. </p>
178
179<p> If at any time in the build process you get messages like: "make:
180don't know how to ..." you should be able to recover by running
181the 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
190machine, it is a good idea to cd into the top-level directory and
191first 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
200compiling 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
205that is better for your system, just cd into the top-level Postfix
206directory 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
215of 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
234By default, Postfix builds as a mail system with relatively few
235bells and whistles. Support for third-party databases etc.
236must 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
2451.0 </td> </tr>
246
247<tr> <td> LDAP database</td> <td>LDAP_README</td> <td> Postfix
2481.0 </td> </tr>
249
250<tr> <td> MySQL database</td> <td>MYSQL_README</td> <td> Postfix
2511.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>
257Postfix 2.0 </td> </tr>
258
259<tr> <td> SASL authentication </td> <td>SASL_README</td> <td>
260Postfix 1.0 </td> </tr>
261
262<tr> <td> SQLite database</td> <td>SQLITE_README</td> <td> Postfix
2632.8 </td> </tr>
264
265<tr> <td> STARTTLS session encryption </td> <td>TLS_README</td> <td>
266Postfix 2.2 </td> </tr>
267
268</table>
269
270</blockquote>
271
272<p> Note: IP version 6 support is compiled into Postfix on operating
273systems 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
279a Postfix configuration file, except for one: the parameter that
280specifies the location of Postfix configuration files. In order to
281build Postfix with a configuration directory other than /etc/postfix,
282use: </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
292a 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
301default</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
341numbers) 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
346is 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
362one or more non-default object libraries. </td> </tr>
363
364<tr> <td colspan="2"> CC=compiler_command</td> <td> Specifies a
365non-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>
369Specifies non-default compiler arguments, for example, a non-default
370<tt>include</tt> directory.  The following directives turn
371off Postfix features at compile time:</td> </tr>
372
373<tr> <td> </td> <td> -DNO_DB </td> <td> Do not build with Berkeley
374DB support. By default, Berkeley DB support is compiled in on
375platforms that are known to support this feature.  </td> </tr>
376
377<tr> <td> </td> <td> -DNO_DEVPOLL </td> <td> Do not build with
378Solaris <tt>/dev/poll</tt> support. By default, <tt>/dev/poll</tt>
379support is compiled in on Solaris versions that are known to support
380this feature.  </td> </tr>
381
382<tr> <td> </td> <td> -DNO_EPOLL </td> <td> Do not build with Linux
383EPOLL support.  By default, EPOLL support is compiled in on platforms
384that are known to support this feature. </td> </tr>
385
386<tr> <td> </td> <td> -DNO_IPV6 </td> <td> Do not build with IPv6
387support. By default, IPv6 support is compiled in on platforms that
388are known to have IPv6 support. Note: this directive is for debugging
389and 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
394support 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
398NISPLUS support. NIS is not available on some recent Linux or Solaris
399distributions. </td> </tr>
400
401<tr> <td> </td> <td> -DNO_PCRE </td> <td> Do not build with PCRE
402support. 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
406for POSIX <tt>getpwnam_r/getpwuid_r</tt>. By default Postfix uses
407these 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>.
411By default, Postfix uses <tt>sigsetjmp()/siglongjmp()</tt> when
412they are known to be available. </td> </tr>
413
414<tr> <td colspan="2"> DEBUG=debug_level </td> <td> Specifies a
415non-default compiler debugging level. The default is <tt>-g</tt>.
416Specify DEBUG= to turn off debugging. </td> </tr>
417
418<tr> <td colspan="2"> OPT=optimization_level </td> <td> Specifies
419a non-default optimization level. The default is -O.  Specify OPT=
420to turn off optimization. </td> </tr>
421
422<tr> <td colspan="2"> WARN="warning_flags..." </td> <td> Specifies
423non-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
432is limited by the number of processes that it can run.  This number
433in turn is limited by the number of files and sockets that a single
434process can open. For example, the Postfix queue manager has a
435separate connection to each delivery process, and the anvil(8)
436server has one connection per smtpd(8) process. </p>
437
438<p> Postfix version 2.4 and later have no built-in limits on the
439number of open files or sockets, when compiled on systems that
440support 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
454of file descriptors per process is limited by the value of the
455FD_SETSIZE macro. If you expect to run more than 1000 mail delivery
456processes, you may need to override the definition of the FD_SETSIZE
457macro 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.
466Apparently, on these systems the FD_SETSIZE value can be changed
467only by using undocumented interfaces. Currently, that means
468including &lt;bits/types.h&gt; directly (which is not allowed) and
469overriding the __FD_SETSIZE macro. Beware, undocumented interfaces
470can change at any time and without warning. </p>
471
472<p> But wait, there is more: none of this will work unless the
473operating system is configured to handle thousands of connections.
474See the TUNING_README guide for examples of how to increase the
475number 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>
488Postfix (section 6).
489
490<p> If the command produces compiler error messages, it may be time
491to search the web or to ask the postfix-users@postfix.org mailing
492list, but be sure to search the mailing list archives first. Some
493mailing 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
498name. Examples:  SUNOS5, FREEBSD4, and so on.  When porting Postfix
499to a new system, the first step is to choose a SYSTEMTYPE name for
500the new system. You must use a name that includes at least the
501major version of the operating system (such as SUNOS4 or LINUX2),
502so that different releases of the same system can be supported
503without confusion.  </p>
504
505<p> Add a case statement to the "makedefs" shell script in the
506source code top-level directory that recognizes the new system
507reliably, and that emits the right system-specific information.
508Be sure to make the code robust against user PATH settings; if the
509system offers multiple UNIX flavors (e.g. BSD and SYSV) be sure to
510build 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
513include file.  You may have to invent new feature macro names.
514Please choose sensible feature macro names such as HAS_DBM or
515FIONREAD_IN_SYS_FILIO_H.
516
517<p> I strongly recommend against using "#ifdef SYSTEMTYPE" in
518individual source files.  While this may look like the quickest
519solution, it will create a mess when newer versions of the same
520SYSTEMTYPE 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
524compilation</a></h2>
525
526<p> This text describes how to install Postfix from source code.
527See the PACKAGE_README file if you are building a package for
528distribution 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
533Sendmail installation with Postfix, you may need to keep the old
534sendmail program running for some time in order to flush the mail
535queue. </p>
536
537<ul>
538
539<li> <p> Some systems implement a mail switch mechanism where
540different MTAs (Postfix, Sendmail, etc.) can be installed at the
541same time, while only one of them is actually being used. Examples
542of such switching mechanisms are the FreeBSD mailwrapper(8) or the
543Linux mail switch.  In this case you should try to "flip" the switch
544to "Postfix" before installing Postfix. </p>
545
546<li> <p> If your system has no mail switch mechanism, execute the
547following commands (your sendmail, newaliases and mailq programs
548may 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
563create an account and a group:</p>
564
565<ul>
566
567<li> <p> Create a user account "postfix" with a user id and group
568id that are not used by any other user account.  Preferably, this
569is an account that no-one can log into.  The account does not need
570an executable login shell, and needs no existing home directory.
571My 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
586by any other user account. Not even by the postfix user account.
587My 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
603one 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
616for Postfix data and program files, and stores your preferences in
617the main.cf file. <b> If you don't want Postfix to overwrite
618non-Postfix "sendmail", "mailq" and "newaliases" files, specify
619pathnames 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
623does not exist, use interactive installation ("make install")
624instead. </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
631your particular machine: </p>
632
633<ul>
634
635<li> <p> <a href="#send_only">Send</a> mail only, without changing
636an existing Sendmail installation (section 7). </p>
637
638<li> <p> <a href="#send_receive">Send and receive</a> mail via a
639virtual host interface, still without any change to an existing
640Sendmail 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
648only</a></h2>
649
650<p> If you are going to use Postfix to send mail only, there is no
651need to change your existing sendmail setup. Instead, set up your
652mail user agent so that it calls the Postfix sendmail program
653directly. </p>
654
655<p> Follow the instructions in the "<a href="#mandatory">Mandatory
656configuration file edits</a>" in section 10, and review the "<a
657href="#hamlet">To chroot or not to chroot</a>" text in section
65811. </p>
659
660<p> You MUST comment out the "smtp inet" entry in /etc/postfix/master.cf,
661in order to avoid conflicts with the real sendmail. Put a "#"
662character 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
688is /var/log/maillog, /var/log/mail, /var/log/syslog, or something
689else. Typically, the pathname is defined in the /etc/syslog.conf
690file. </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
699messages are not as useful. </p>
700
701<p> In order to inspect the mail queue, use one of the following
702commands: </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
715below.  </p>
716
717<h2><a name="send_receive">8 - Configuring Postfix to send and
718receive mail via virtual interface</a></h2>
719
720<p> Alternatively, you can use the Postfix system to send AND
721receive mail while leaving your Sendmail setup intact, by running
722Postfix on a virtual interface address.  Simply configure your mail
723user agent to directly invoke the Postfix sendmail program.  </p>
724
725<p> To create a virtual network interface address, study your
726system ifconfig manual page. The command syntax could be any
727of: </p>
728
729<blockquote>
730<pre>
731# <b>ifconfig le0:1 &lt;address&gt; netmask &lt;mask&gt; up</b>
732# <b>ifconfig en0 alias &lt;address&gt; 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
748configuration file edits</a>" in section 10, and review the "<a
749name="#hamlet">To chroot or not to chroot</a>" text in section
75011. </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
769is /var/log/maillog, /var/log/mail, /var/log/syslog, or something
770else. Typically, the pathname is defined in the /etc/syslog.conf
771file. </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
780messages are not as useful. </p>
781
782<p> In order to inspect the mail queue, use one of the following
783commands: </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
796below.  </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>
801any existing sendmail program files as described in section 6.  Be
802sure to keep the old sendmail running for at least a couple days
803to flush any unsent mail. To do so, stop the sendmail daemon and
804restart 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
813processes for mail submission and for running the queue. </p>
814
815<p> After you have visited the "<a href="#mandatory">Mandatory
816configuration file edits</a>" section below, you can start the
817Postfix 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
834is /var/log/maillog, /var/log/mail, /var/log/syslog, or something
835else. Typically, the pathname is defined in the /etc/syslog.conf
836file. </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
845messages are not as useful. </p>
846
847<p> In order to inspect the mail queue, use one of the following
848commands: </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
861below.  </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
866detail in the BASIC_CONFIGURATION_README document. The information
867presented 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.
873The two most important files are main.cf and master.cf; these files
874must be owned by root.  Giving someone else write permission to
875main.cf or master.cf (or to their parent directories) means giving
876root privileges to that person. </p>
877
878<p> In /etc/postfix/main.cf, you will have to set up a minimal number
879of configuration parameters.  Postfix configuration parameters
880resemble shell variables, with two important differences: the first
881one is that Postfix does not know about quotes like the UNIX shell
882does.</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
903second main difference with UNIX shell variables). The Postfix
904configuration language uses lazy evaluation, and does not look at
905a 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,
908execute the following command in order to refresh a running mail
909system: </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
920unqualified address (i.e. an address without @domain.tld). The
921"myorigin" parameter defaults to the local hostname, but that is
922probably 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
937locally. </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
951is appropriate for the mailserver for an entire domain. The third
952example 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
957that Postfix receives mail on by way of a proxy or network address
958translation unit. You may specify symbolic hostnames instead of
959network addresses. </p>
960
961<p> IMPORTANT: You must specify your proxy/NAT external addresses
962when your system is a backup MX host for other domains, otherwise
963mail 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
978what client IP addresses are authorized to relay their mail through
979your machine into the Internet.  The default setting includes all
980subnetworks that the machine is attached to. This may give relay
981permission 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
993whether Postfix will forward mail from strangers.  The default
994setting will forward mail to all domains (and subdomains of) what
995is listed in $mydestination.  This may give relay permission for
996too 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
1010you can, specify the organizational domain name so that Postfix
1011can use DNS lookups, and so that it can fall back to a secondary
1012MX host when the primary MX host is down. Otherwise just specify
1013a 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
1028specify a relay host. If your machine has no access to a DNS server,
1029turn 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
1039firewalled 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
1044mail for local(8) recipients.  Typically, this information is kept
1045in 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
1047the exact location of the text file.  </p>
1048
1049<p> First, be sure to update the text file with aliases for root,
1050postmaster and "postfix" that forward mail to a real person.  Postfix
1051has a sample aliases file /etc/postfix/aliases that you can adapt
1052to 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
1068following 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
1080run in a chroot jail.  The processes run at a fixed low privilege
1081and with access only to the Postfix queue directories (/var/spool/postfix).
1082This provides a significant barrier against intrusion. The barrier
1083is not impenetrable, but every little bit helps. </p>
1084
1085<p> With the exception of Postfix daemons that deliver mail locally
1086and/or that execute non-Postfix commands, every Postfix daemon can
1087run chrooted. </p>
1088
1089<p> Sites with high security requirements should consider to chroot
1090all daemons that talk to the network:  the smtp(8) and smtpd(8)
1091processes, and perhaps also the lmtp(8) client. The author's own
1092porcupine.org mail server runs all daemons chrooted that can be
1093chrooted. </p>
1094
1095<p> The default /etc/postfix/master.cf file specifies that no
1096Postfix daemon runs chrooted.  In order to enable chroot operation,
1097edit 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
1101the Postfix queue directory (/var/spool/postfix). For successful
1102use of a chroot jail,  most UNIX systems require you to bring in
1103some files or device nodes.  The examples/chroot-setup directory
1104in the source code distribution has a collection of scripts that
1105help you set up Postfix chroot environments on different operating
1106systems. </p>
1107
1108<p> Additionally, you almost certainly need to configure syslogd
1109so that it listens on a socket inside the Postfix queue directory.
1110Examples 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
1133and normal activity to the syslog daemon. The names of logfiles
1134are specified in /etc/syslog.conf. At the very least you need
1135something 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
1146them before (re)starting syslogd. </p>
1147
1148<p> IMPORTANT: on Linux you need to put a "-" character before
1149the pathname, e.g., -/var/log/maillog, otherwise the syslogd
1150will use more system resources than Postfix does. </p>
1151
1152<p> Hopefully, the number of problems will be small, but it is a good
1153idea 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
1165file permission/ownership discrepancies. </p>
1166
1167<li> <p> The second line looks for problem reports from the mail
1168software, and reports how effective the relay and junk mail access
1169blocks are.  This may produce a lot of output.  You will want to
1170apply some postprocessing to eliminate uninteresting information.
1171</p>
1172
1173</ul>
1174
1175<p>  The <a href="DEBUG_README.html#logging"> DEBUG_README </a>
1176document describes the meaning of the "warning" etc. labels in
1177Postfix logging. </p>
1178
1179</body>
1180
1181</html>
1182