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 <a href="BASIC_CONFIGURATION_README.html">BASIC_CONFIGURATION_README</a> and the general documentation 25referenced by it. <a href="INSTALL.html">INSTALL</a> 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 <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 <a href="postconf.5.html">postconf(5)</a> 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> Postfix development happens on FreeBSD and MacOS X, with regular 139tests on Linux (Fedora, Ubuntu) and Solaris. Support for other 140systems relies on feedback from their users, and may not always be 141up-to-date. </p> 142 143<p> OpenBSD is partially supported. The libc resolver does not 144implement the documented "internal resolver options which are [...] 145set by changing fields in the _res structure" (documented in the 146OpenBSD 5.6 resolver(3) manpage). This results in too many DNS 147queries, and false positives for queries that should fail. </p> 148 149<!-- 150 151<p> At some point in time, a version of Postfix was supported on: </p> 152 153<blockquote> 154<p> 155AIX 3.2.5, 4.1.x, 4.2.0, 4.3.x, 5.2 <br> 156BSD/OS 2.x, 3.x, 4.x <br> 157FreeBSD 2.x .. 9.x <br> 158HP-UX 9.x, 10.x, 11.x <br> 159IRIX 5.x, 6.x <br> 160Linux Debian 1.3.1 and later <br> 161Linux RedHat 3.x (January 2004) and later <br> 162Linux Slackware 3.x and later <br> 163Linux SuSE 5.x and later <br> 164Linux Ubuntu 4.10 and later<br> 165Mac OS X <br> 166NEXTSTEP 3.x <br> 167NetBSD 1.x and later <br> 168OPENSTEP 4.x <br> 169OSF1.V3 - OSF1.V5 (Digital UNIX) <br> 170Reliant UNIX 5.x <br> 171SunOS 4.1.4 (March 2007) <br> 172SunOS 5.4 - 5.10 (Solaris 2.4..10) <br> 173Ultrix 4.x (well, that was long ago) <br> 174</p> 175</blockquote> 176 177<p> or something closely resemblant. </p> 178 179--> 180 181<p> Overview of topics: </p> 182 183<ul> 184 185<li><a href="#build_first">4.1 - Getting started</a> 186 187<li><a href="#build_cc">4.2 - What compiler to use</a> 188 189<li><a href="#build_pie">4.3 - Building with Postfix position-independent 190executables (Postfix ≥ 3.0)</a> 191 192<li><a href="#build_dll">4.4 - Building with Postfix dynamically-linked 193libraries and database plugins (Postfix ≥ 3.0)</a> 194 195<li><a href="#build_opt">4.5 - Building with optional features</a> 196 197<li><a href="#build_over">4.6 - Overriding built-in parameter default 198settings</a> 199 200<li><a href="#build_other">4.7 - Overriding other compile-time 201features</a> 202 203<li><a href="#build_proc">4.8 - Support for thousands of processes</a> 204 205<li><a href="#build_final">4.9 - Compiling Postfix, at last</a> 206 207</ul> 208 209 210<h3><a name="build_first">4.1 - Getting started</a> </h3> 211 212<p> On Solaris, the "make" command and other development utilities 213are in /usr/ccs/bin, so you MUST have /usr/ccs/bin in your command 214search path. If these files do not exist, you need to install the 215development packages first. </p> 216 217<p> If you need to build Postfix for multiple architectures from a 218single source-code tree, use the "lndir" command to build a shadow 219tree with symbolic links to the source files. </p> 220 221<p> If at any time in the build process you get messages like: "make: 222don't know how to ..." you should be able to recover by running 223the following command from the Postfix top-level directory: </p> 224 225<blockquote> 226<pre> 227$ make -f Makefile.init makefiles 228</pre> 229</blockquote> 230 231<p> If you copied the Postfix source code after building it on another 232machine, it is a good idea to cd into the top-level directory and 233first do this:</p> 234 235<blockquote> 236<pre> 237$ make tidy 238</pre> 239</blockquote> 240 241<p> This will get rid of any system dependencies left over from 242compiling the software elsewhere. </p> 243 244<h3><a name="build_cc">4.2 - What compiler to use</a></h3> 245 246<p> To build with GCC, or with the native compiler if people told me 247that is better for your system, just cd into the top-level Postfix 248directory of the source tree and type: </p> 249 250<blockquote> 251<pre> 252$ make 253</pre> 254</blockquote> 255 256<p> To build with a non-default compiler, you need to specify the name 257of the compiler. Here are a few examples: </p> 258 259<blockquote> 260<pre> 261$ make makefiles CC=/opt/SUNWspro/bin/cc (Solaris) 262$ make 263 264$ make makefiles CC="/opt/ansic/bin/cc -Ae" (HP-UX) 265$ make 266 267$ make makefiles CC="purify cc" 268$ make 269</pre> 270</blockquote> 271 272<p> and so on. In some cases, optimization will be turned off 273automatically. </p> 274 275<h3><a name="build_pie">4.3 - Building with Postfix position-independent 276executables (Postfix ≥ 3.0)</a> </h3> 277 278<p> On some systems Postfix can be built with Position-Independent 279Executables. PIE is used by the ASLR exploit mitigation technique 280(ASLR = Address-Space Layout Randomization): </p> 281 282<blockquote> 283<pre> 284$ make makefiles pie=yes ...other arguments... 285</pre> 286</blockquote> 287 288<p> (Specify "make makefiles pie=no" to explicitly disable Postfix 289position-independent executable support). </p> 290 291<p> Postfix PIE support appears to work on Fedora Core 20, Ubuntu 29214.04, FreeBSD 9 and 10, and NetBSD 6 (all with the default system 293compilers). </p> 294 295<p> Whether the "pie=yes" above has any effect depends on the 296compiler. Some compilers always produce PIE executables, and some 297may even complain that the Postfix build option is redundant. </p> 298 299<h3><a name="build_dll">4.4 - Building with Postfix dynamically-linked 300libraries and database plugins (Postfix ≥ 3.0)</a> </h3> 301 302<p> Postfix dynamically-linked library and database plugin support 303exists for recent versions of Linux, FreeBSD and MacOS X. 304Dynamically-linked library builds may become the default at some 305point in the future. </p> 306 307<p> Overview of topics: </p> 308 309<ul> 310 311<li><a href="#shared_enable">4.4.1 Turning on Postfix dynamically-linked 312library support</a> 313 314<li><a href="#dynamicmaps_enable">4.4.2 Turning on Postfix database-plugin 315support</a> 316 317<li><a href="#shared_custom">4.4.3 Customizing Postfix dynamically-linked 318libraries and database plugins</a> 319 320<li><a href="#shared_tips">4.4.4 Tips for distribution maintainers</a> 321 322</ul> 323 324<p> Note: directories with Postfix dynamically-linked libraries 325or database plugins should contain only postfix-related files. 326Postfix dynamically-linked libraries and database plugins should 327not be installed in a "public" system directory such as /usr/lib 328or /usr/local/lib. Linking Postfix dynamically-linked library or 329database-plugin files into non-Postfix programs is not supported. 330Postfix dynamically-linked libraries and database plugins implement 331a Postfix-internal API that changes without maintaining compatibility. 332</p> 333 334<h4><a name="shared_enable"> 4.4.1 Turning on Postfix dynamically-linked 335library support </a></h4> 336 337<p> Postfix can be built with Postfix dynamically-linked libraries 338(files typically named <tt>libpostfix-*.so</tt>). Postfix 339dynamically-linked libraries add minor run-time overhead and result 340in significantly-smaller Postfix executable files. </p> 341 342<p> Specify "shared=yes" on the "make makefiles" command line to 343build Postfix with dynamically-linked library support. </p> 344 345<blockquote> 346<pre> 347$ make makefiles shared=yes ...other arguments... 348$ make 349</pre> 350</blockquote> 351 352<p> (Specify "make makefiles shared=no" to explicitly disable Postfix 353dynamically-linked library support). </p> 354 355<p> This installs dynamically-linked libraries in $<a href="postconf.5.html#shlib_directory">shlib_directory</a>, 356typically /usr/lib/postfix or /usr/local/lib/postfix, with file 357names libpostfix-<i>name</i>.so, where the <i>name</i> is a source-code 358directory name such as "util" or "global". </p> 359 360<p> See section 4.4.3 "<a href="#shared_custom">Customizing Postfix 361dynamically-linked libraries and database plugins</a>" below for 362how to customize the Postfix dynamically-linked library location, 363including support to upgrade a running mail system safely. </p> 364 365<h4><a name="dynamicmaps_enable"> 4.4.2 Turning on Postfix 366database-plugin support </a></h4> 367 368<p> Additionally, Postfix can be built to support dynamic loading 369of Postfix database clients (database plugins) with the Debian-style 370dynamicmaps feature. Postfix 3.0 supports dynamic loading of <a href="CDB_README.html">cdb</a>:, 371<a href="ldap_table.5.html">ldap</a>:, <a href="lmdb_table.5.html">lmdb</a>:, <a href="mysql_table.5.html">mysql</a>:, <a href="pcre_table.5.html">pcre</a>:, <a href="pgsql_table.5.html">pgsql</a>:, <a href="DATABASE_README.html#types">sdbm</a>:, and <a href="sqlite_table.5.html">sqlite</a>: database 372clients. Dynamic loading is useful when you distribute or install 373pre-compiled Postfix packages. </p> 374 375<p> Specify "dynamicmaps=yes" on the "make makefiles" command line 376to build Postfix with support to dynamically load Postfix database 377clients with the Debian-style dynamicmaps feature. 378</p> 379 380<blockquote> 381<pre> 382$ make makefiles dynamicmaps=yes ...other arguments... 383$ make 384</pre> 385</blockquote> 386 387<p> (Specify "make makefiles dynamicmaps=no" to explicitly disable 388Postfix database-plugin support). </p> 389 390<p> This implicitly enables dynamically-linked library support, 391installs the configuration file dynamicmaps.cf in $<a href="postconf.5.html#meta_directory">meta_directory</a> 392(usually, /etc/postfix or /usr/local/etc/postfix), and installs 393database plugins in $<a href="postconf.5.html#shlib_directory">shlib_directory</a> (see above). Database plugins 394are named postfix-<i>type</i>.so where the <i>type</i> is a database 395type such as "cdb" or "ldap". </p> 396 397<blockquote> 398 399<p> NOTE: The Postfix 3.0 build procedure expects that you specify 400database library dependencies with variables named <a href="CDB_README.html">AUXLIBS_CDB</a>, 401<a href="LDAP_README.html">AUXLIBS_LDAP</a>, etc. With Postfix 3.0 and later, the old AUXLIBS 402variable still supports building a statically-loaded database client, 403but only the new <a href="CDB_README.html">AUXLIBS_CDB</a> etc. variables support building a 404dynamically-loaded or statically-loaded CDB etc. database client. 405See <a href="CDB_README.html">CDB_README</a>, <a href="LDAP_README.html">LDAP_README</a>, etc. for details. </p> 406 407<p> Failure to follow this advice will defeat the purpose of dynamic 408database client loading. Every Postfix executable file will have 409database library dependencies. And that was exactly what dynamic 410database client loading was meant to avoid. </p> 411 412</blockquote> 413 414<p> See the next section for how to customize the location and 415version of Postfix database plugins and the location of the file 416dynamicmaps.cf. </p> 417 418<h4><a name="shared_custom"> 4.4.3 Customizing Postfix dynamically-linked 419libraries and database plugins </a></h4> 420 421<h5> Customizing build-time and run-time options for Postfix 422dynamically-linked libraries and database plugins </h5> 423 424<p> The build-time environment variables SHLIB_CFLAGS, SHLIB_RPATH, 425and SHLIB_SUFFIX provide control over how Postfix libraries and 426plugins are compiled, linked, and named. 427 428<blockquote> 429<pre> 430$ make makefiles SHLIB_CFLAGS=flags SHLIB_RPATH=rpath SHLIB_SUFFIX=suffix ...other arguments... 431$ make 432</pre> 433</blockquote> 434 435<p> See section 4.7 "<a href="#build_other">Overriding other 436compile-time features</a>" below for details. </p> 437 438<h5> Customizing the location of Postfix dynamically-linked libraries 439and database plugins </h5> 440 441<p> As a reminder, the directories with Postfix dynamically-linked 442libraries or database plugins should contain only Postfix-related 443files. Linking these files into other programs is not supported. 444</p> 445 446<p> To override the default location of Postfix dynamically-linked 447libraries and database plugins specify, for example: </p> 448 449<blockquote> 450<pre> 451$ make makefiles shared=yes <a href="postconf.5.html#shlib_directory">shlib_directory</a>=/usr/local/lib/postfix ... 452</pre> 453</blockquote> 454 455<p> If you intend to upgrade Postfix without stopping the mail 456system, then you should append the Postfix release version to the 457<a href="postconf.5.html#shlib_directory">shlib_directory</a> pathname, to eliminate the possibility that programs 458will link with dynamically-linked libraries or database plugins 459from the wrong Postfix version. For example: </p> 460 461<blockquote> 462<pre> 463$ make makefiles shared=yes \ 464 <a href="postconf.5.html#shlib_directory">shlib_directory</a>=/usr/local/lib/postfix/MAIL_VERSION ... 465</pre> 466</blockquote> 467 468<p> The command "make makefiles name=value..." will replace the 469string MAIL_VERSION at the end of a configuration parameter value 470with the Postfix release version. Do not try to specify something 471like $<a href="postconf.5.html#mail_version">mail_version</a> on this command line. This produces inconsistent 472results with different versions of the make(1) command. </p> 473 474<p> You can change the <a href="postconf.5.html#shlib_directory">shlib_directory</a> setting after Postfix is 475built, with "make install" or "make upgrade". However, you may have 476to run ldconfig if you change <a href="postconf.5.html#shlib_directory">shlib_directory</a> after Postfix is built 477(the symptom is that Postfix programs fail because the run-time 478linker cannot find the files libpostfix-*.so). No ldconfig command 479is needed if you keep the files libpostfix-*.so in the compiled-in 480default $<a href="postconf.5.html#shlib_directory">shlib_directory</a> location. </p> 481 482<blockquote> 483<pre> 484# make upgrade <a href="postconf.5.html#shlib_directory">shlib_directory</a>=/usr/local/lib/postfix ... 485# make install <a href="postconf.5.html#shlib_directory">shlib_directory</a>=/usr/local/lib/postfix ... 486</pre> 487</blockquote> 488 489<p> To append the Postfix release version to the pathname if you 490intend to upgrade Postfix without stopping the mail system: </p> 491 492<blockquote> 493<pre> 494# make upgrade <a href="postconf.5.html#shlib_directory">shlib_directory</a>=/usr/local/lib/postfix/MAIL_VERSION ... 495# make install <a href="postconf.5.html#shlib_directory">shlib_directory</a>=/usr/local/lib/postfix/MAIL_VERSION ... 496</pre> 497</blockquote> 498 499<p> See also the comments above for appending MAIL_VERSION with 500the "make makefiles" command. </p> 501 502<h5> Customizing the location of dynamicmaps.cf and other files 503</h5> 504 505<p> The <a href="postconf.5.html#meta_directory">meta_directory</a> parameter has the same default setting as 506the <a href="postconf.5.html#config_directory">config_directory</a> parameter, typically /etc/postfix or 507/usr/local/etc/postfix. </p> 508 509<p> You can override the default <a href="postconf.5.html#meta_directory">meta_directory</a> location at compile 510time or after Postfix is built. To override the default location 511at compile time specify, for example: </p> 512 513<blockquote> 514<pre> 515% make makefiles <a href="postconf.5.html#meta_directory">meta_directory</a>=/usr/libexec/postfix ... 516</pre> 517</blockquote> 518 519<p> Here is a tip if you want to make a pathname dependent on the 520Postfix release version: the command "make makefiles name=value..." 521will replace the string MAIL_VERSION at the end of a configuration 522parameter value with the Postfix release version. Do not try to 523specify something like $<a href="postconf.5.html#mail_version">mail_version</a> on this command line. This 524produces inconsistent results with different versions of the make(1) 525command. </p> 526 527<p> You can override the <a href="postconf.5.html#meta_directory">meta_directory</a> setting after Postfix is 528built, with "make install" or "make upgrade". </p> 529 530<blockquote> 531<pre> 532# make upgrade <a href="postconf.5.html#meta_directory">meta_directory</a>=/usr/libexec/postfix ... 533# make install <a href="postconf.5.html#meta_directory">meta_directory</a>=/usr/libexec/postfix ... 534</pre> 535</blockquote> 536 537<p> As with the command "make makefiles, the command "make 538install/upgrade name=value..." will replace the string MAIL_VERSION 539at the end of a configuration parameter value with the Postfix 540release version. Do not try to specify something like $<a href="postconf.5.html#mail_version">mail_version</a> 541on this command line. This produces inconsistent results with 542different versions of the make(1) command. </p> 543 544<h4><a name="shared_tips"> 4.4.4 Tips for distribution maintainers 545</a></h4> 546 547<ul> 548 549<li> <p> The <a href="postconf.5.html#shlib_directory">shlib_directory</a> parameter setting also provides the 550default directory for database plugin files with a relative pathname 551in the file dynamicmaps.cf. </p> 552 553<li> <p> The <a href="postconf.5.html#meta_directory">meta_directory</a> parameter specifies the location of the 554files dynamicmaps.cf, postfix-files, and some multi-instance template 555files. The <a href="postconf.5.html#meta_directory">meta_directory</a> parameter has the same default value as 556the <a href="postconf.5.html#config_directory">config_directory</a> parameter (typically, /etc/postfix or 557/usr/local/etc/postfix). For backwards compatibility with Postfix 5582.6 .. 2.11, specify "<a href="postconf.5.html#meta_directory">meta_directory</a> = $<a href="postconf.5.html#daemon_directory">daemon_directory</a>" in <a href="postconf.5.html">main.cf</a> 559before installing or upgrading Postfix, or specify "<a href="postconf.5.html#meta_directory">meta_directory</a> 560= /path/name" on the "make makefiles", "make install" or "make 561upgrade" command line. </p> 562 563<li> <p> The configuration file dynamicmaps.cf will automatically 564include files under the directory dynamicmaps.cf.d, just like the 565configuration file postfix-files will automatically include files 566under the directory postfix-files.d. Thanks to this, you can install 567or deinstall a database plugin package without having to edit 568postfix-files or dynamicmaps.cf. Instead, you give that plugin its 569own configuration files under dynamicmaps.cf.d and postfix-files.d, and 570you add or remove those configuration files along with the database 571plugin dynamically-linked object. </p> 572 573<li> <p> Each configuration file under the directory dynamicmaps.cf.d 574must have the same format as the configuration file dynamicmaps.cf. 575There is no requirement that these configuration file *names* have a 576specific format. </p> 577 578<li> <p> Each configuration file under the directory postfix-files.d 579must have the same format as the configuration file postfix-files. 580There is no requirement that these configuration file *names* have a 581specific format. </p> 582 583</ul> 584 585<h3><a name="build_opt">4.5 - Building with optional features</a></h3> 586 587By default, Postfix builds as a mail system with relatively few 588bells and whistles. Support for third-party databases etc. 589must be configured when Postfix is compiled. The following documents 590describe how to build Postfix with support for optional features: 591 592<blockquote> 593<table border="1"> 594 595<tr> <th>Optional feature </th> <th>Document </th> <th>Availability</th> 596</tr> 597 598<tr> <td> Berkeley DB database</td> <td><a href="DB_README.html">DB_README</a></td> <td> Postfix 5991.0 </td> </tr> 600 601<tr> <td> LMDB database</td> <td><a href="LMDB_README.html">LMDB_README</a></td> <td> Postfix 6022.11 </td> </tr> 603 604<tr> <td> LDAP database</td> <td><a href="LDAP_README.html">LDAP_README</a></td> <td> Postfix 6051.0 </td> </tr> 606 607<tr> <td> MySQL database</td> <td><a href="MYSQL_README.html">MYSQL_README</a></td> <td> Postfix 6081.0 </td> </tr> 609 610<tr> <td> Perl compatible regular expression</td> <td><a href="PCRE_README.html">PCRE_README</a></td> 611<td> Postfix 1.0 </td> </tr> 612 613<tr> <td> PostgreSQL database</td> <td><a href="PGSQL_README.html">PGSQL_README</a></td> <td> 614Postfix 2.0 </td> </tr> 615 616<tr> <td> SASL authentication </td> <td><a href="SASL_README.html">SASL_README</a></td> <td> 617Postfix 1.0 </td> </tr> 618 619<tr> <td> SQLite database</td> <td><a href="SQLITE_README.html">SQLITE_README</a></td> <td> Postfix 6202.8 </td> </tr> 621 622<tr> <td> STARTTLS session encryption </td> <td><a href="TLS_README.html">TLS_README</a></td> <td> 623Postfix 2.2 </td> </tr> 624 625</table> 626 627</blockquote> 628 629<p> Note: IP version 6 support is compiled into Postfix on operating 630systems that have IPv6 support. See the <a href="IPV6_README.html">IPV6_README</a> file for details. 631</p> 632 633<h3><a name="build_over">4.6 - Overriding built-in parameter default 634settings</a></h3> 635 636<h4>4.6.1 - Postfix 3.0 and later </h4> 637 638<p> All Postfix configuration parameters can be changed by editing 639a Postfix configuration file, except for one: the parameter that 640specifies the location of Postfix configuration files. In order to 641build Postfix with a configuration directory other than /etc/postfix, 642use: </p> 643 644<blockquote> 645<pre> 646$ make makefiles <a href="postconf.5.html#config_directory">config_directory</a>=/some/where ...other arguments... 647$ make 648</pre> 649</blockquote> 650 651<p> The command "make makefiles name=value ..." will replace the 652string MAIL_VERSION at the end of a configuration parameter value 653with the Postfix release version. Do not try to specify something 654like $<a href="postconf.5.html#mail_version">mail_version</a> on this command line. This produces inconsistent 655results with different versions of the make(1) command. </p> 656 657<p> Parameters whose defaults can be specified in this way are 658listed below. See the <a href="postconf.5.html">postconf(5)</a> manpage for a description 659(command: "<tt>nroff -man man/man5/postconf.5 | less</tt>"). </p> 660 661<blockquote> 662 663<table border="1"> 664 665<tr> <th>parameter name</th> <th>typical default</th> </tr> 666 667<tr> <td><a href="postconf.5.html#command_directory">command_directory</a></td> <td>/usr/sbin</td> </tr> 668 669<tr> <td><a href="postconf.5.html#config_directory">config_directory</a></td> <td>/etc/postfix</td> </tr> 670 671<tr> <td><a href="postconf.5.html#default_database_type">default_database_type</a></td> <td>hash</td> </tr> 672 673<tr> <td><a href="postconf.5.html#daemon_directory">daemon_directory</a></td> <td>/usr/libexec/postfix</td> </tr> 674 675<tr> <td><a href="postconf.5.html#data_directory">data_directory</a></td> <td>/var/lib/postfix</td> </tr> 676 677<tr> <td><a href="postconf.5.html#html_directory">html_directory</a></td> <td>no</td> </tr> 678 679<tr> <td><a href="postconf.5.html#mail_spool_directory">mail_spool_directory</a></td> <td>/var/mail</td> </tr> 680 681<tr> <td><a href="postconf.5.html#mailq_path">mailq_path</a></td> <td>/usr/bin/mailq</td> </tr> 682 683<tr> <td><a href="postconf.5.html#manpage_directory">manpage_directory</a></td> <td>/usr/local/man</td> </tr> 684 685<tr> <td><a href="postconf.5.html#meta_directory">meta_directory</a></td> <td>/etc/postfix</td> </tr> 686 687<tr> <td><a href="postconf.5.html#newaliases_path">newaliases_path</a></td> <td>/usr/bin/newaliases</td> </tr> 688 689<tr> <td><a href="postconf.5.html#openssl_path">openssl_path</a></td> <td>openssl</td> </tr> 690 691<tr> <td><a href="postconf.5.html#queue_directory">queue_directory</a></td> <td>/var/spool/postfix</td> </tr> 692 693<tr> <td><a href="postconf.5.html#readme_directory">readme_directory</a></td> <td>no</td> </tr> 694 695<tr> <td><a href="postconf.5.html#sendmail_path">sendmail_path</a></td> <td>/usr/sbin/sendmail</td> </tr> 696 697<tr> <td><a href="postconf.5.html#shlib_directory">shlib_directory</a></td> <td>/usr/lib/postfix</td> </tr> 698 699</table> 700 701</blockquote> 702 703<h4>4.6.2 - All Postfix versions </h4> 704 705<p> All Postfix configuration parameters can be changed by editing 706a Postfix configuration file, except for one: the parameter that 707specifies the location of Postfix configuration files. In order to 708build Postfix with a configuration directory other than /etc/postfix, 709use: </p> 710 711<blockquote> 712<pre> 713$ make makefiles CCARGS='-DDEF_CONFIG_DIR=\"/some/where\"' 714$ make 715</pre> 716</blockquote> 717 718<p> IMPORTANT: Be sure to get the quotes right. These details matter 719a lot. </p> 720 721<p> Parameters whose defaults can be specified in this way are 722listed below. See the <a href="postconf.5.html">postconf(5)</a> manpage for a description 723(command: "<tt>nroff -man man/man5/postconf.5 | less</tt>"). </p> 724 725<blockquote> 726 727<table border="1"> 728 729<tr><th> Macro name </th> <th>default value for</th> <th>typical 730default</th> </tr> 731 732<tr> <td>DEF_COMMAND_DIR</td> <td><a href="postconf.5.html#command_directory">command_directory</a></td> 733<td>/usr/sbin</td> </tr> 734 735<tr> <td>DEF_CONFIG_DIR</td> <td><a href="postconf.5.html#config_directory">config_directory</a></td> 736<td>/etc/postfix</td> </tr> 737 738<tr> <td>DEF_DB_TYPE</td> <td><a href="postconf.5.html#default_database_type">default_database_type</a></td> 739<td>hash</td> </tr> 740 741<tr> <td>DEF_DAEMON_DIR</td> <td><a href="postconf.5.html#daemon_directory">daemon_directory</a></td> 742<td>/usr/libexec/postfix</td> </tr> 743 744<tr> <td>DEF_DATA_DIR</td> <td><a href="postconf.5.html#data_directory">data_directory</a></td> 745<td>/var/db/postfix</td> </tr> 746 747<tr> <td>DEF_MAILQ_PATH</td> <td><a href="postconf.5.html#mailq_path">mailq_path</a></td> <td>/usr/bin/mailq</td> 748</tr> 749 750<tr> <td>DEF_HTML_DIR</td> <td><a href="postconf.5.html#html_directory">html_directory</a></td> 751<td>no</td> </tr> 752 753<tr> <td>DEF_MANPAGE_DIR</td> <td><a href="postconf.5.html#manpage_directory">manpage_directory</a></td> 754<td>/usr/local/man</td> </tr> 755 756<tr> <td>DEF_NEWALIAS_PATH</td> <td><a href="postconf.5.html#newaliases_path">newaliases_path</a></td> 757<td>/usr/bin/newaliases</td> </tr> 758 759<tr> <td>DEF_QUEUE_DIR</td> <td><a href="postconf.5.html#queue_directory">queue_directory</a></td> 760<td>/var/spool/postfix</td> </tr> 761 762<tr> <td>DEF_README_DIR</td> <td><a href="postconf.5.html#readme_directory">readme_directory</a></td> 763<td>no</td> </tr> 764 765<tr> <td>DEF_SENDMAIL_PATH</td> <td><a href="postconf.5.html#sendmail_path">sendmail_path</a></td> 766<td>/usr/sbin/sendmail</td> </tr> 767 768</table> 769 770</blockquote> 771 772<p> Note: the <a href="postconf.5.html#data_directory">data_directory</a> parameter (for caches and pseudo-random 773numbers) was introduced with Postfix version 2.5. </p> 774 775<h3><a name="build_other">4.7 - Overriding other compile-time 776features</a></h3> 777 778<p> The general method to override Postfix compile-time features 779is as follows: </p> 780 781<blockquote> 782<pre> 783$ make makefiles name=value name=value... 784$ make 785</pre> 786</blockquote> 787 788<p> The following is an extensive list of names and values. </p> 789 790<table border="1"> 791 792<tr> <th colspan="2"> Name/Value </th> <th> Description </th> </tr> 793 794<tr> <td colspan="2"> AUXLIBS="object_library..."</td> <td> Specifies 795one or more non-default object libraries. Postfix 3.0 and later 796specify some of their database library dependencies with <a href="CDB_README.html">AUXLIBS_CDB</a>, 797<a href="LDAP_README.html">AUXLIBS_LDAP</a>, <a href="LMDB_README.html">AUXLIBS_LMDB</a>, <a href="MYSQL_README.html">AUXLIBS_MYSQL</a>, <a href="PCRE_README.html">AUXLIBS_PCRE</a>, <a href="PGSQL_README.html">AUXLIBS_PGSQL</a>, 798<a href="SDBM_README.html">AUXLIBS_SDBM</a>, and <a href="SQLITE_README.html">AUXLIBS_SQLITE</a>, respectively. </td> </tr> 799 800<tr> <td colspan="2"> CC=compiler_command</td> <td> Specifies a 801non-default compiler. On many systems, the default is <tt>gcc</tt>. 802</td> </tr> 803 804<tr> <td colspan="2"> CCARGS="compiler_arguments..."</td> <td> 805Specifies non-default compiler arguments, for example, a non-default 806<tt>include</tt> directory. The following directives turn 807off Postfix features at compile time:</td> </tr> 808 809<tr> <td> </td> <td> -DNO_DB </td> <td> Do not build with Berkeley 810DB support. By default, Berkeley DB support is compiled in on 811platforms that are known to support this feature. If you override 812this, then you probably should also override DEF_DB_TYPE as described 813in section 4.6. </td> </tr> 814 815<tr> <td> </td> <td> -DNO_DNSSEC </td> <td> Do not build with DNSSEC 816support, even if the resolver library appears to support it. </td> 817</tr> 818 819<tr> <td> </td> <td> -DNO_DEVPOLL </td> <td> Do not build with 820Solaris <tt>/dev/poll</tt> support. By default, <tt>/dev/poll</tt> 821support is compiled in on Solaris versions that are known to support 822this feature. </td> </tr> 823 824<tr> <td> </td> <td> -DNO_EPOLL </td> <td> Do not build with Linux 825EPOLL support. By default, EPOLL support is compiled in on platforms 826that are known to support this feature. </td> </tr> 827 828<tr> <td> </td> <td> -DNO_EAI </td> <td> Do not build with EAI 829(SMTPUTF8) support. By default, EAI support is compiled in when 830the "icuuc" library and header files are found. </td> </tr> 831 832<tr> <td> </td> <td> -DNO_INLINE </td> <td> Do not require support 833for C99 "inline" functions. Instead, implement argument typechecks 834for non-printf/scanf-like functions with ternary operators and 835unreachable code. </td> </tr> 836 837<tr> <td> </td> <td> -DNO_IPV6 </td> <td> Do not build with IPv6 838support. By default, IPv6 support is compiled in on platforms that 839are known to have IPv6 support. Note: this directive is for debugging 840And testing only. It is not guaranteed to work on all platforms. 841If you don't want IPv6 support, set "<a href="postconf.5.html#inet_protocols">inet_protocols</a> = ipv4" in 842<a href="postconf.5.html">main.cf</a>. 843</td> </tr> 844 845<tr> <td> </td> <td> -DNO_KQUEUE </td> <td> Do not build with FreeBSD 846/ NetBSD / OpenBSD / MacOSX KQUEUE support. By default, KQUEUE 847support is compiled in on platforms that are known to support it. 848</td> </tr> 849 850<tr> <td> </td> <td> -DNO_NIS </td> <td> Do not build with NIS or 851NISPLUS support. NIS is not available on some recent Linux 852distributions. </td> </tr> 853 854<tr> <td> </td> <td> -DNO_NISPLUS </td> <td> Do not build with 855NISPLUS support. NISPLUS is not available on some recent Solaris 856distributions. </td> </tr> 857 858<tr> <td> </td> <td> -DNO_PCRE </td> <td> Do not build with PCRE 859support. By default, PCRE support is compiled in when the 860<tt>pcre-config</tt> utility is installed. </td> </tr> 861 862<tr> <td> </td> <td> -DNO_POSIX_GETPW_R </td> <td> Disable support 863for POSIX <tt>getpwnam_r/getpwuid_r</tt>. By default Postfix uses 864these where they are known to be available. </td> </tr> 865 866<tr> <td> </td> <td> -DNO_SIGSETJMP </td> <td> Use 867<tt>setjmp()/longjmp()</tt> instead of <tt>sigsetjmp()/siglongjmp()</tt>. 868By default, Postfix uses <tt>sigsetjmp()/siglongjmp()</tt> when 869they are known to be available. </td> </tr> 870 871<tr> <td> </td> <td> -DNO_SNPRINTF </td> <td> Use <tt>sprintf()</tt> 872instead of <tt>snprintf()</tt>. By default, Postfix uses 873<tt>snprintf()</tt> except on ancient systems. </td> </tr> 874 875<tr> <td colspan="2"> DEBUG=debug_level </td> <td> Specifies a 876non-default compiler debugging level. The default is "<tt>-g</tt>". 877Specify DEBUG= to turn off debugging. </td> </tr> 878 879<tr> <td colspan="2"> OPT=optimization_level </td> <td> Specifies 880a non-default optimization level. The default is "<tt>-O</tt>". 881Specify OPT= to turn off optimization. </td> </tr> 882 883<tr> <td colspan="2"> POSTFIX_INSTALL_OPTS=-option... </td> <td> 884Specifies options for the <tt>postfix-install</tt> command, separated 885by whitespace. Currently, the only supported option is 886"<tt>-keep-build-mtime</tt>". </td> </tr> 887 888<tr> <td colspan="2"> SHLIB_CFLAGS=flags </td> <td> Specifies 889non-default compiler options for building Postfix dynamically-linked 890libraries and database plugins. The typical default is "-fPIC". 891</td> </tr> 892 893<tr> <td colspan="2"> SHLIB_RPATH=rpath </td> <td> Specifies 894a non-default runpath for Postfix dynamically-linked libraries. The 895typical default is "'-Wl,-rpath,${SHLIB_DIR}'". </td> </tr> 896 897<tr> <td colspan="2"> SHLIB_SUFFIX=suffix </td> <td> Specifies 898a non-default suffix for Postfix dynamically-linked libraries and 899database plugins. The typical default is "<tt>.so</tt>". </td> 900</tr> 901 902<tr> <td colspan="2"> WARN="warning_flags..." </td> <td> Specifies 903non-default compiler warning options for use when "<tt>make</tt>" 904is invoked in a source subdirectory only. </td> 905</tr> 906 907</table> 908 909<h3><a name="build_proc">4.8 - Support for thousands of processes</a></h3> 910 911<p> The number of connections that Postfix can manage simultaneously 912is limited by the number of processes that it can run. This number 913in turn is limited by the number of files and sockets that a single 914process can open. For example, the Postfix queue manager has a 915separate connection to each delivery process, and the <a href="anvil.8.html">anvil(8)</a> 916server has one connection per <a href="smtpd.8.html">smtpd(8)</a> process. </p> 917 918<p> Postfix version 2.4 and later have no built-in limits on the 919number of open files or sockets, when compiled on systems that 920support one of the following: </p> 921 922<ul> 923 924<li> BSD kqueue(2) (FreeBSD 4.1, NetBSD 2.0, OpenBSD 2.9), 925 926<li> Solaris 8 /dev/poll, 927 928<li> Linux 2.6 epoll(4). 929 930</ul> 931 932 933<p> With other Postfix versions or operating systems, the number 934of file descriptors per process is limited by the value of the 935FD_SETSIZE macro. If you expect to run more than 1000 mail delivery 936processes, you may need to override the definition of the FD_SETSIZE 937macro to make select() work correctly: </p> 938 939<blockquote> 940<pre> 941$ make makefiles CCARGS=-DFD_SETSIZE=2048 942</pre> 943</blockquote> 944 945<p> Warning: the above has no effect on some Linux versions. 946Apparently, on these systems the FD_SETSIZE value can be changed 947only by using undocumented interfaces. Currently, that means 948including <bits/types.h> directly (which is not allowed) and 949overriding the __FD_SETSIZE macro. Beware, undocumented interfaces 950can change at any time and without warning. </p> 951 952<p> But wait, there is more: none of this will work unless the 953operating system is configured to handle thousands of connections. 954See the <a href="TUNING_README.html">TUNING_README</a> guide for examples of how to increase the 955number of open sockets or files. </p> 956 957<h3><a name="build_final">4.9 - Compiling Postfix, at last</a></h3> 958 959<p> If the command </p> 960 961<blockquote> 962<pre> 963$ make 964</pre> 965</blockquote> 966 967<p> is successful, then you can proceed to <a href="#install">install</a> 968Postfix (section 6). 969 970<p> If the command produces compiler error messages, it may be time 971to search the web or to ask the postfix-users@postfix.org mailing 972list, but be sure to search the mailing list archives first. Some 973mailing list archives are linked from <a href="http://www.postfix.org/">http://www.postfix.org/</a>. </p> 974 975<h2> <a name="5">5 - Porting Postfix to an unsupported system</a> </h2> 976 977<p> Each system type that Postfix knows is identified by a unique 978name. Examples: SUNOS5, FREEBSD4, and so on. When porting Postfix 979to a new system, the first step is to choose a SYSTEMTYPE name for 980the new system. You must use a name that includes at least the 981major version of the operating system (such as SUNOS4 or LINUX2), 982so that different releases of the same system can be supported 983without confusion. </p> 984 985<p> Add a case statement to the "makedefs" shell script in the 986source code top-level directory that recognizes the new system 987reliably, and that emits the right system-specific information. 988Be sure to make the code robust against user PATH settings; if the 989system offers multiple UNIX flavors (e.g. BSD and SYSV) be sure to 990build for the native flavor, instead of the emulated one. </p> 991 992<p> Add an "#ifdef SYSTEMTYPE" section to the central util/sys_defs.h 993include file. You may have to invent new feature macro names. 994Please choose sensible feature macro names such as HAS_DBM or 995FIONREAD_IN_SYS_FILIO_H. 996 997<p> I strongly recommend against using "#ifdef SYSTEMTYPE" in 998individual source files. While this may look like the quickest 999solution, it will create a mess when newer versions of the same 1000SYSTEMTYPE need to be supported. You're likely to end up placing 1001"#ifdef" sections all over the source code again. </p> 1002 1003<h2><a name="install">6 - Installing the software after successful 1004compilation</a></h2> 1005 1006<p> This text describes how to install Postfix from source code. 1007See the <a href="PACKAGE_README.html">PACKAGE_README</a> file if you are building a package for 1008distribution to other systems. </p> 1009 1010<h3>6.1 - Save existing Sendmail binaries</h3> 1011 1012<p> <a name="save">IMPORTANT</a>: if you are REPLACING an existing 1013Sendmail installation with Postfix, you may need to keep the old 1014sendmail program running for some time in order to flush the mail 1015queue. </p> 1016 1017<ul> 1018 1019<li> <p> Some systems implement a mail switch mechanism where 1020different MTAs (Postfix, Sendmail, etc.) can be installed at the 1021same time, while only one of them is actually being used. Examples 1022of such switching mechanisms are the FreeBSD mailwrapper(8) or the 1023Linux mail switch. In this case you should try to "flip" the switch 1024to "Postfix" before installing Postfix. </p> 1025 1026<li> <p> If your system has no mail switch mechanism, execute the 1027following commands (your sendmail, newaliases and mailq programs 1028may be in a different place): </p> 1029 1030<pre> 1031# mv /usr/sbin/sendmail /usr/sbin/sendmail.OFF 1032# mv /usr/bin/newaliases /usr/bin/newaliases.OFF 1033# mv /usr/bin/mailq /usr/bin/mailq.OFF 1034# chmod 755 /usr/sbin/sendmail.OFF /usr/bin/newaliases.OFF \ 1035 /usr/bin/mailq.OFF 1036</pre> 1037 1038</ul> 1039 1040<h3>6.2 - Create account and groups</h3> 1041 1042<p> Before you install Postfix for the first time you need to 1043create an account and a group:</p> 1044 1045<ul> 1046 1047<li> <p> Create a user account "postfix" with a user id and group 1048id that are not used by any other user account. Preferably, this 1049is an account that no-one can log into. The account does not need 1050an executable login shell, and needs no existing home directory. 1051My password and group file entries look like this: </p> 1052 1053<blockquote> 1054<pre> 1055/etc/passwd: 1056 postfix:*:12345:12345:postfix:/no/where:/no/shell 1057 1058/etc/group: 1059 postfix:*:12345: 1060</pre> 1061</blockquote> 1062 1063<p> Note: there should be no whitespace before "postfix:". </p> 1064 1065<li> <p> Create a group "postdrop" with a group id that is not used 1066by any other user account. Not even by the postfix user account. 1067My group file entry looks like: 1068 1069<blockquote> 1070<pre> 1071/etc/group: 1072 postdrop:*:54321: 1073</pre> 1074</blockquote> 1075 1076<p> Note: there should be no whitespace before "postdrop:". </p> 1077 1078</ul> 1079 1080<h3>6.3 - Install Postfix</h3> 1081 1082<p> To install or upgrade Postfix from compiled source code, run 1083one of the following commands as the super-user:</p> 1084 1085<blockquote> 1086<pre> 1087# make install (interactive version, first time install) 1088 1089# make upgrade (non-interactive version, for upgrades) 1090</pre> 1091</blockquote> 1092 1093<ul> 1094 1095<li> <p> The interactive version ("make install") asks for pathnames 1096for Postfix data and program files, and stores your preferences in 1097the <a href="postconf.5.html">main.cf</a> file. <b> If you don't want Postfix to overwrite 1098non-Postfix "sendmail", "mailq" and "newaliases" files, specify 1099pathnames that end in ".postfix"</b>. </p> 1100 1101<li> <p> The non-interactive version ("make upgrade") needs the 1102/etc/postfix/<a href="postconf.5.html">main.cf</a> file from a previous installation. If the file 1103does not exist, use interactive installation ("make install") 1104instead. </p> 1105 1106<li> <p> If you specify name=value arguments on the "make install" 1107or "make upgrade" command line, then these will take precedence 1108over compiled-in default settings or <a href="postconf.5.html">main.cf</a> settings. </p> 1109 1110<p> The command "make install/upgrade name=value ..." will replace 1111the string MAIL_VERSION at the end of a configuration parameter 1112value with the Postfix release version. Do not try to specify 1113something like $<a href="postconf.5.html#mail_version">mail_version</a> on this command line. This produces 1114inconsistent results with different versions of the make(1) command. 1115</p> 1116 1117</ul> 1118 1119<h3>6.4 - Configure Postfix</h3> 1120 1121<p> Proceed to the section on how you wish to run Postfix on 1122your particular machine: </p> 1123 1124<ul> 1125 1126<li> <p> <a href="#send_only">Send</a> mail only, without changing 1127an existing Sendmail installation (section 7). </p> 1128 1129<li> <p> <a href="#send_receive">Send and receive</a> mail via a 1130virtual host interface, still without any change to an existing 1131Sendmail installation (section 8). </p> 1132 1133<li> <p> Run Postfix <a href="#replace">instead of</a> Sendmail 1134(section 9). </p> 1135 1136</ul> 1137 1138<h2><a name="send_only">7 - Configuring Postfix to send mail 1139only</a></h2> 1140 1141<p> If you are going to use Postfix to send mail only, there is no 1142need to change your existing sendmail setup. Instead, set up your 1143mail user agent so that it calls the Postfix sendmail program 1144directly. </p> 1145 1146<p> Follow the instructions in the "<a href="#mandatory">Mandatory 1147configuration file edits</a>" in section 10, and review the "<a 1148href="#hamlet">To chroot or not to chroot</a>" text in section 114911. </p> 1150 1151<p> You MUST comment out the "smtp inet" entry in /etc/postfix/<a href="master.5.html">master.cf</a>, 1152in order to avoid conflicts with the real sendmail. Put a "#" 1153character in front of the line that defines the smtpd service: </p> 1154 1155<blockquote> 1156<pre> 1157/etc/postfix/<a href="master.5.html">master.cf</a>: 1158 #smtp inet n - n - - smtpd 1159</pre> 1160</blockquote> 1161 1162<p> Start the Postfix system: </p> 1163 1164<blockquote> 1165<pre> 1166# postfix start 1167</pre> 1168</blockquote> 1169 1170<p> or, if you feel nostalgic, use the Postfix sendmail command: </p> 1171 1172<blockquote> 1173<pre> 1174# sendmail -bd -qwhatever 1175</pre> 1176</blockquote> 1177 1178<p> and watch your maillog file for any error messages. The pathname 1179is /var/log/maillog, /var/log/mail, /var/log/syslog, or something 1180else. Typically, the pathname is defined in the /etc/syslog.conf 1181file. </p> 1182 1183<blockquote> 1184<pre> 1185$ egrep '(reject|warning|error|fatal|panic):' /some/log/file 1186</pre> 1187</blockquote> 1188 1189<p> Note: the most important error message is logged first. Later 1190messages are not as useful. </p> 1191 1192<p> In order to inspect the mail queue, use one of the following 1193commands: </p> 1194 1195<blockquote> 1196<pre> 1197$ mailq 1198 1199$ sendmail -bp 1200 1201$ postqueue -p 1202</pre> 1203</blockquote> 1204 1205<p> See also the "<a href="#care">Care and feeding</a>" section 12 1206below. </p> 1207 1208<h2><a name="send_receive">8 - Configuring Postfix to send and 1209receive mail via virtual interface</a></h2> 1210 1211<p> Alternatively, you can use the Postfix system to send AND 1212receive mail while leaving your Sendmail setup intact, by running 1213Postfix on a virtual interface address. Simply configure your mail 1214user agent to directly invoke the Postfix sendmail program. </p> 1215 1216<p> To create a virtual network interface address, study your 1217system ifconfig manual page. The command syntax could be any 1218of: </p> 1219 1220<blockquote> 1221<pre> 1222# <b>ifconfig le0:1 <address> netmask <mask> up</b> 1223# <b>ifconfig en0 alias <address> netmask 255.255.255.255</b> 1224</pre> 1225</blockquote> 1226 1227<p> In the /etc/postfix/<a href="postconf.5.html">main.cf</a> file, I would specify </p> 1228 1229<blockquote> 1230<pre> 1231/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1232 <a href="postconf.5.html#myhostname">myhostname</a> = virtual.host.tld 1233 <a href="postconf.5.html#inet_interfaces">inet_interfaces</a> = $<a href="postconf.5.html#myhostname">myhostname</a> 1234 <a href="postconf.5.html#mydestination">mydestination</a> = $<a href="postconf.5.html#myhostname">myhostname</a> 1235</pre> 1236</blockquote> 1237 1238<p> Follow the instructions in the "<a href="#mandatory">Mandatory 1239configuration file edits</a>" in section 10, and review the "<a 1240name="#hamlet">To chroot or not to chroot</a>" text in section 124111. </p> 1242 1243<p> Start the Postfix system: </p> 1244 1245<blockquote> 1246<pre> 1247# postfix start 1248</pre> 1249</blockquote> 1250 1251<p> or, if you feel nostalgic, use the Postfix sendmail command: </p> 1252 1253<blockquote> 1254<pre> 1255# sendmail -bd -qwhatever 1256</pre> 1257</blockquote> 1258 1259<p> and watch your maillog file for any error messages. The pathname 1260is /var/log/maillog, /var/log/mail, /var/log/syslog, or something 1261else. Typically, the pathname is defined in the /etc/syslog.conf 1262file. </p> 1263 1264<blockquote> 1265<pre> 1266$ egrep '(reject|warning|error|fatal|panic):' /some/log/file 1267</pre> 1268</blockquote> 1269 1270<p> Note: the most important error message is logged first. Later 1271messages are not as useful. </p> 1272 1273<p> In order to inspect the mail queue, use one of the following 1274commands: </p> 1275 1276<blockquote> 1277<pre> 1278$ mailq 1279 1280$ sendmail -bp 1281 1282$ postqueue -p 1283</pre> 1284</blockquote> 1285 1286<p> See also the "<a href="#care">Care and feeding</a>" section 12 1287below. </p> 1288 1289<h2><a name="replace">9 - Running Postfix instead of Sendmail</a></h2> 1290 1291<p> Prior to installing Postfix you should <a href="#save">save</a> 1292any existing sendmail program files as described in section 6. Be 1293sure to keep the old sendmail running for at least a couple days 1294to flush any unsent mail. To do so, stop the sendmail daemon and 1295restart it as: </p> 1296 1297<blockquote> 1298<pre> 1299# /usr/sbin/sendmail.OFF -q 1300</pre> 1301</blockquote> 1302 1303<p> Note: this is old sendmail syntax. Newer versions use separate 1304processes for mail submission and for running the queue. </p> 1305 1306<p> After you have visited the "<a href="#mandatory">Mandatory 1307configuration file edits</a>" section below, you can start the 1308Postfix system with: </p> 1309 1310<blockquote> 1311<pre> 1312# postfix start 1313</pre> 1314</blockquote> 1315 1316<p> or, if you feel nostalgic, use the Postfix sendmail command: </p> 1317 1318<blockquote> 1319<pre> 1320# sendmail -bd -qwhatever 1321</pre> 1322</blockquote> 1323 1324<p> and watch your maillog file for any error messages. The pathname 1325is /var/log/maillog, /var/log/mail, /var/log/syslog, or something 1326else. Typically, the pathname is defined in the /etc/syslog.conf 1327file. </p> 1328 1329<blockquote> 1330<pre> 1331$ egrep '(reject|warning|error|fatal|panic):' /some/log/file 1332</pre> 1333</blockquote> 1334 1335<p> Note: the most important error message is logged first. Later 1336messages are not as useful. </p> 1337 1338<p> In order to inspect the mail queue, use one of the following 1339commands: </p> 1340 1341<blockquote> 1342<pre> 1343$ mailq 1344 1345$ sendmail -bp 1346 1347$ postqueue -p 1348</pre> 1349</blockquote> 1350 1351<p> See also the "<a href="#care">Care and feeding</a>" section 12 1352below. </p> 1353 1354<h2><a name="mandatory">10 - Mandatory configuration file edits</a></h2> 1355 1356<p> Note: the material covered in this section is covered in more 1357detail in the <a href="BASIC_CONFIGURATION_README.html">BASIC_CONFIGURATION_README</a> document. The information 1358presented below is targeted at experienced system administrators. 1359</p> 1360 1361<h3>10.1 - Postfix configuration files</h3> 1362 1363<p> By default, Postfix configuration files are in /etc/postfix. 1364The two most important files are <a href="postconf.5.html">main.cf</a> and <a href="master.5.html">master.cf</a>; these files 1365must be owned by root. Giving someone else write permission to 1366<a href="postconf.5.html">main.cf</a> or <a href="master.5.html">master.cf</a> (or to their parent directories) means giving 1367root privileges to that person. </p> 1368 1369<p> In /etc/postfix/<a href="postconf.5.html">main.cf</a>, you will have to set up a minimal number 1370of configuration parameters. Postfix configuration parameters 1371resemble shell variables, with two important differences: the first 1372one is that Postfix does not know about quotes like the UNIX shell 1373does.</p> 1374 1375<p> You specify a configuration parameter as: </p> 1376 1377<blockquote> 1378<pre> 1379/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1380 parameter = value 1381</pre> 1382</blockquote> 1383 1384<p> and you use it by putting a "$" character in front of its name: </p> 1385 1386<blockquote> 1387<pre> 1388/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1389 other_parameter = $parameter 1390</pre> 1391</blockquote> 1392 1393<p> You can use $parameter before it is given a value (that is the 1394second main difference with UNIX shell variables). The Postfix 1395configuration language uses lazy evaluation, and does not look at 1396a parameter value until it is needed at runtime. </p> 1397 1398<p> Whenever you make a change to the <a href="postconf.5.html">main.cf</a> or <a href="master.5.html">master.cf</a> file, 1399execute the following command in order to refresh a running mail 1400system: </p> 1401 1402<blockquote> 1403<pre> 1404# postfix reload 1405</pre> 1406</blockquote> 1407 1408<h3>10.2 - Default domain for unqualified addresses</h3> 1409 1410<p> First of all, you must specify what domain will be appended to an 1411unqualified address (i.e. an address without @domain.tld). The 1412"<a href="postconf.5.html#myorigin">myorigin</a>" parameter defaults to the local hostname, but that is 1413probably OK only for very small sites. </p> 1414 1415<p> Some examples (use only one): </p> 1416 1417<blockquote> 1418<pre> 1419/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1420 <a href="postconf.5.html#myorigin">myorigin</a> = $<a href="postconf.5.html#myhostname">myhostname</a> (send mail as "user@$<a href="postconf.5.html#myhostname">myhostname</a>") 1421 <a href="postconf.5.html#myorigin">myorigin</a> = $<a href="postconf.5.html#mydomain">mydomain</a> (send mail as "user@$<a href="postconf.5.html#mydomain">mydomain</a>") 1422</pre> 1423</blockquote> 1424 1425<h3>10.3 - What domains to receive locally</h3> 1426 1427<p> Next you need to specify what mail addresses Postfix should deliver 1428locally. </p> 1429 1430<p> Some examples (use only one): </p> 1431 1432<blockquote> 1433<pre> 1434/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1435 <a href="postconf.5.html#mydestination">mydestination</a> = $<a href="postconf.5.html#myhostname">myhostname</a>, localhost.$<a href="postconf.5.html#mydomain">mydomain</a>, localhost 1436 <a href="postconf.5.html#mydestination">mydestination</a> = $<a href="postconf.5.html#myhostname">myhostname</a>, localhost.$<a href="postconf.5.html#mydomain">mydomain</a>, localhost, $<a href="postconf.5.html#mydomain">mydomain</a> 1437 <a href="postconf.5.html#mydestination">mydestination</a> = $<a href="postconf.5.html#myhostname">myhostname</a> 1438</pre> 1439</blockquote> 1440 1441<p>The first example is appropriate for a workstation, the second 1442is appropriate for the mailserver for an entire domain. The third 1443example should be used when running on a virtual host interface.</p> 1444 1445<h3>10.4 - Proxy/NAT interface addresses </h3> 1446 1447<p> The <a href="postconf.5.html#proxy_interfaces">proxy_interfaces</a> parameter specifies all network addresses 1448that Postfix receives mail on by way of a proxy or network address 1449translation unit. You may specify symbolic hostnames instead of 1450network addresses. </p> 1451 1452<p> IMPORTANT: You must specify your proxy/NAT external addresses 1453when your system is a backup MX host for other domains, otherwise 1454mail delivery loops will happen when the primary MX host is down. 1455</p> 1456 1457<p> Example: host behind NAT box running a backup MX host. </p> 1458 1459<blockquote> 1460<pre> 1461/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1462 <a href="postconf.5.html#proxy_interfaces">proxy_interfaces</a> = 1.2.3.4 (the proxy/NAT external network address) 1463</pre> 1464</blockquote> 1465 1466<h3>10.5 - What local clients to relay mail from </h3> 1467 1468<p> If your machine is on an open network then you must specify 1469what client IP addresses are authorized to relay their mail through 1470your machine into the Internet. The default setting includes all 1471subnetworks that the machine is attached to. This may give relay 1472permission to too many clients. My own settings are: </p> 1473 1474<blockquote> 1475<pre> 1476/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1477 <a href="postconf.5.html#mynetworks">mynetworks</a> = 168.100.189.0/28, 127.0.0.0/8 1478</pre> 1479</blockquote> 1480 1481<h3>10.6 - What relay destinations to accept from strangers </h3> 1482 1483<p> If your machine is on an open network then you must also specify 1484whether Postfix will forward mail from strangers. The default 1485setting will forward mail to all domains (and subdomains of) what 1486is listed in $<a href="postconf.5.html#mydestination">mydestination</a>. This may give relay permission for 1487too many destinations. Recommended settings (use only one): </p> 1488 1489<blockquote> 1490<pre> 1491/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1492 <a href="postconf.5.html#relay_domains">relay_domains</a> = (do not forward mail from strangers) 1493 <a href="postconf.5.html#relay_domains">relay_domains</a> = $<a href="postconf.5.html#mydomain">mydomain</a> (my domain and subdomains) 1494 <a href="postconf.5.html#relay_domains">relay_domains</a> = $<a href="postconf.5.html#mydomain">mydomain</a>, other.domain.tld, ... 1495</pre> 1496</blockquote> 1497 1498<h3>10.7 - Optional: configure a smart host for remote delivery</h3> 1499 1500<p> If you're behind a firewall, you should set up a <a href="postconf.5.html#relayhost">relayhost</a>. If 1501you can, specify the organizational domain name so that Postfix 1502can use DNS lookups, and so that it can fall back to a secondary 1503MX host when the primary MX host is down. Otherwise just specify 1504a hard-coded hostname. </p> 1505 1506<p> Some examples (use only one): </p> 1507 1508<blockquote> 1509<pre> 1510/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1511 <a href="postconf.5.html#relayhost">relayhost</a> = $<a href="postconf.5.html#mydomain">mydomain</a> 1512 <a href="postconf.5.html#relayhost">relayhost</a> = [mail.$<a href="postconf.5.html#mydomain">mydomain</a>] 1513</pre> 1514</blockquote> 1515 1516<p> The form enclosed with <tt>[]</tt> eliminates DNS MX lookups. </p> 1517 1518<p> By default, the SMTP client will do DNS lookups even when you 1519specify a <a href="postconf.5.html#relayhost">relay host</a>. If your machine has no access to a DNS server, 1520turn off SMTP client DNS lookups like this: </p> 1521 1522<blockquote> 1523<pre> 1524/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1525 <a href="postconf.5.html#disable_dns_lookups">disable_dns_lookups</a> = yes 1526</pre> 1527</blockquote> 1528 1529<p> The <a href="STANDARD_CONFIGURATION_README.html">STANDARD_CONFIGURATION_README</a> file has more hints and tips for 1530firewalled and/or dial-up networks. </p> 1531 1532<h3>10.8 - Create the aliases database</h3> 1533 1534<p> Postfix uses a Sendmail-compatible <a href="aliases.5.html">aliases(5)</a> table to redirect 1535mail for <a href="local.8.html">local(8)</a> recipients. Typically, this information is kept 1536in two files: in a text file /etc/aliases and in an indexed file 1537/etc/aliases.db. The command "postconf <a href="postconf.5.html#alias_maps">alias_maps</a>" will tell you 1538the exact location of the text file. </p> 1539 1540<p> First, be sure to update the text file with aliases for root, 1541postmaster and "postfix" that forward mail to a real person. Postfix 1542has a sample aliases file /etc/postfix/aliases that you can adapt 1543to local conditions. </p> 1544 1545<blockquote> 1546<pre> 1547/etc/aliases: 1548 root: you 1549 postmaster: root 1550 postfix: root 1551 bin: root 1552 <i>etcetera...</i> 1553</pre> 1554</blockquote> 1555 1556<p> Note: there should be no whitespace before the ":". </p> 1557 1558<p> Finally, build the indexed aliases file with one of the 1559following commands: </p> 1560 1561<blockquote> 1562<pre> 1563# newaliases 1564# sendmail -bi 1565</pre> 1566</blockquote> 1567 1568<h2><a name="hamlet">11 - To chroot or not to chroot</a></h2> 1569 1570<p> Postfix daemon processes can be configured (via <a href="master.5.html">master.cf</a>) to 1571run in a chroot jail. The processes run at a fixed low privilege 1572and with access only to the Postfix queue directories (/var/spool/postfix). 1573This provides a significant barrier against intrusion. The barrier 1574is not impenetrable, but every little bit helps. </p> 1575 1576<p> With the exception of Postfix daemons that deliver mail locally 1577and/or that execute non-Postfix commands, every Postfix daemon can 1578run chrooted. </p> 1579 1580<p> Sites with high security requirements should consider to chroot 1581all daemons that talk to the network: the <a href="smtp.8.html">smtp(8)</a> and <a href="smtpd.8.html">smtpd(8)</a> 1582processes, and perhaps also the <a href="lmtp.8.html">lmtp(8)</a> client. The author's own 1583porcupine.org mail server runs all daemons chrooted that can be 1584chrooted. </p> 1585 1586<p> The default /etc/postfix/<a href="master.5.html">master.cf</a> file specifies that no 1587Postfix daemon runs chrooted. In order to enable chroot operation, 1588edit the file /etc/postfix/<a href="master.5.html">master.cf</a>. Instructions are in the file. 1589</p> 1590 1591<p> Note that a chrooted daemon resolves all filenames relative to 1592the Postfix queue directory (/var/spool/postfix). For successful 1593use of a chroot jail, most UNIX systems require you to bring in 1594some files or device nodes. The examples/chroot-setup directory 1595in the source code distribution has a collection of scripts that 1596help you set up Postfix chroot environments on different operating 1597systems. </p> 1598 1599<p> Additionally, you almost certainly need to configure syslogd 1600so that it listens on a socket inside the Postfix queue directory. 1601Examples for specific systems: </p> 1602 1603<dl> 1604 1605<dt> FreeBSD: </dt> 1606 1607<dd> <pre> 1608# mkdir -p /var/spool/postfix/var/run 1609# syslogd -l /var/spool/postfix/var/run/log 1610</pre> </dd> 1611 1612<dt> Linux, OpenBSD: </dt> 1613 1614<dd> <pre> 1615# mkdir -p /var/spool/postfix/dev 1616# syslogd -a /var/spool/postfix/dev/log 1617</pre> </dd> 1618 1619</dl> 1620 1621<h2><a name="care">12 - Care and feeding of the Postfix system</a></h2> 1622 1623<p> Postfix daemon processes run in the background, and log problems 1624and normal activity to the syslog daemon. The names of logfiles 1625are specified in /etc/syslog.conf. At the very least you need 1626something like: </p> 1627 1628<blockquote> 1629<pre> 1630/etc/syslog.conf: 1631 mail.err /dev/console 1632 mail.debug /var/log/maillog 1633</pre> 1634</blockquote> 1635 1636<p> IMPORTANT: the syslogd will not create files. You must create 1637them before (re)starting syslogd. </p> 1638 1639<p> IMPORTANT: on Linux you need to put a "-" character before 1640the pathname, e.g., -/var/log/maillog, otherwise the syslogd 1641will use more system resources than Postfix does. </p> 1642 1643<p> Hopefully, the number of problems will be small, but it is a good 1644idea to run every night before the syslog files are rotated: </p> 1645 1646<blockquote> 1647<pre> 1648# postfix check 1649# egrep '(reject|warning|error|fatal|panic):' /some/log/file 1650</pre> 1651</blockquote> 1652 1653<ul> 1654 1655<li> <p> The first line (postfix check) causes Postfix to report 1656file permission/ownership discrepancies. </p> 1657 1658<li> <p> The second line looks for problem reports from the mail 1659software, and reports how effective the relay and junk mail access 1660blocks are. This may produce a lot of output. You will want to 1661apply some postprocessing to eliminate uninteresting information. 1662</p> 1663 1664</ul> 1665 1666<p> The <a href="DEBUG_README.html#logging"> DEBUG_README </a> 1667document describes the meaning of the "warning" etc. labels in 1668Postfix logging. </p> 1669 1670</body> 1671 1672</html> 1673