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 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>openssl_path</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. 841</td> </tr> 842 843<tr> <td> </td> <td> -DNO_KQUEUE </td> <td> Do not build with FreeBSD 844/ NetBSD / OpenBSD / MacOSX KQUEUE support. By default, KQUEUE 845support is compiled in on platforms that are known to support it. 846</td> </tr> 847 848<tr> <td> </td> <td> -DNO_NIS </td> <td> Do not build with NIS or 849NISPLUS support. NIS is not available on some recent Linux 850distributions. </td> </tr> 851 852<tr> <td> </td> <td> -DNO_NISPLUS </td> <td> Do not build with 853NISPLUS support. NISPLUS is not available on some recent Solaris 854distributions. </td> </tr> 855 856<tr> <td> </td> <td> -DNO_PCRE </td> <td> Do not build with PCRE 857support. By default, PCRE support is compiled in when the 858<tt>pcre-config</tt> utility is installed. </td> </tr> 859 860<tr> <td> </td> <td> -DNO_POSIX_GETPW_R </td> <td> Disable support 861for POSIX <tt>getpwnam_r/getpwuid_r</tt>. By default Postfix uses 862these where they are known to be available. </td> </tr> 863 864<tr> <td> </td> <td> -DNO_SIGSETJMP </td> <td> Use 865<tt>setjmp()/longjmp()</tt> instead of <tt>sigsetjmp()/siglongjmp()</tt>. 866By default, Postfix uses <tt>sigsetjmp()/siglongjmp()</tt> when 867they are known to be available. </td> </tr> 868 869<tr> <td colspan="2"> DEBUG=debug_level </td> <td> Specifies a 870non-default compiler debugging level. The default is "<tt>-g</tt>". 871Specify DEBUG= to turn off debugging. </td> </tr> 872 873<tr> <td colspan="2"> OPT=optimization_level </td> <td> Specifies 874a non-default optimization level. The default is "<tt>-O</tt>". 875Specify OPT= to turn off optimization. </td> </tr> 876 877<tr> <td colspan="2"> SHLIB_CFLAGS=flags </td> <td> Specifies 878non-default compiler options for building Postfix dynamically-linked 879libraries and database plugins. The typical default is "-fPIC". 880</td> </tr> 881 882<tr> <td colspan="2"> SHLIB_RPATH=rpath </td> <td> Specifies 883a non-default runpath for Postfix dynamically-linked libraries. The 884typical default is "'-Wl,-rpath,${SHLIB_DIR}'". </td> </tr> 885 886<tr> <td colspan="2"> SHLIB_SUFFIX=suffix </td> <td> Specifies 887a non-default suffix for Postfix dynamically-linked libraries and 888database plugins. The typical default is "<tt>.so</tt>". </td> 889</tr> 890 891<tr> <td colspan="2"> WARN="warning_flags..." </td> <td> Specifies 892non-default compiler warning options for use when "<tt>make</tt>" 893is invoked in a source subdirectory only. </td> 894</tr> 895 896</table> 897 898<h3><a name="build_proc">4.8 - Support for thousands of processes</a></h3> 899 900<p> The number of connections that Postfix can manage simultaneously 901is limited by the number of processes that it can run. This number 902in turn is limited by the number of files and sockets that a single 903process can open. For example, the Postfix queue manager has a 904separate connection to each delivery process, and the <a href="anvil.8.html">anvil(8)</a> 905server has one connection per <a href="smtpd.8.html">smtpd(8)</a> process. </p> 906 907<p> Postfix version 2.4 and later have no built-in limits on the 908number of open files or sockets, when compiled on systems that 909support one of the following: </p> 910 911<ul> 912 913<li> BSD kqueue(2) (FreeBSD 4.1, NetBSD 2.0, OpenBSD 2.9), 914 915<li> Solaris 8 /dev/poll, 916 917<li> Linux 2.6 epoll(4). 918 919</ul> 920 921 922<p> With other Postfix versions or operating systems, the number 923of file descriptors per process is limited by the value of the 924FD_SETSIZE macro. If you expect to run more than 1000 mail delivery 925processes, you may need to override the definition of the FD_SETSIZE 926macro to make select() work correctly: </p> 927 928<blockquote> 929<pre> 930$ make makefiles CCARGS=-DFD_SETSIZE=2048 931</pre> 932</blockquote> 933 934<p> Warning: the above has no effect on some Linux versions. 935Apparently, on these systems the FD_SETSIZE value can be changed 936only by using undocumented interfaces. Currently, that means 937including <bits/types.h> directly (which is not allowed) and 938overriding the __FD_SETSIZE macro. Beware, undocumented interfaces 939can change at any time and without warning. </p> 940 941<p> But wait, there is more: none of this will work unless the 942operating system is configured to handle thousands of connections. 943See the <a href="TUNING_README.html">TUNING_README</a> guide for examples of how to increase the 944number of open sockets or files. </p> 945 946<h3><a name="build_final">4.9 - Compiling Postfix, at last</a></h3> 947 948<p> If the command </p> 949 950<blockquote> 951<pre> 952$ make 953</pre> 954</blockquote> 955 956<p> is successful, then you can proceed to <a href="#install">install</a> 957Postfix (section 6). 958 959<p> If the command produces compiler error messages, it may be time 960to search the web or to ask the postfix-users@postfix.org mailing 961list, but be sure to search the mailing list archives first. Some 962mailing list archives are linked from <a href="http://www.postfix.org/">http://www.postfix.org/</a>. </p> 963 964<h2> <a name="5">5 - Porting Postfix to an unsupported system</a> </h2> 965 966<p> Each system type that Postfix knows is identified by a unique 967name. Examples: SUNOS5, FREEBSD4, and so on. When porting Postfix 968to a new system, the first step is to choose a SYSTEMTYPE name for 969the new system. You must use a name that includes at least the 970major version of the operating system (such as SUNOS4 or LINUX2), 971so that different releases of the same system can be supported 972without confusion. </p> 973 974<p> Add a case statement to the "makedefs" shell script in the 975source code top-level directory that recognizes the new system 976reliably, and that emits the right system-specific information. 977Be sure to make the code robust against user PATH settings; if the 978system offers multiple UNIX flavors (e.g. BSD and SYSV) be sure to 979build for the native flavor, instead of the emulated one. </p> 980 981<p> Add an "#ifdef SYSTEMTYPE" section to the central util/sys_defs.h 982include file. You may have to invent new feature macro names. 983Please choose sensible feature macro names such as HAS_DBM or 984FIONREAD_IN_SYS_FILIO_H. 985 986<p> I strongly recommend against using "#ifdef SYSTEMTYPE" in 987individual source files. While this may look like the quickest 988solution, it will create a mess when newer versions of the same 989SYSTEMTYPE need to be supported. You're likely to end up placing 990"#ifdef" sections all over the source code again. </p> 991 992<h2><a name="install">6 - Installing the software after successful 993compilation</a></h2> 994 995<p> This text describes how to install Postfix from source code. 996See the <a href="PACKAGE_README.html">PACKAGE_README</a> file if you are building a package for 997distribution to other systems. </p> 998 999<h3>6.1 - Save existing Sendmail binaries</h3> 1000 1001<p> <a name="save">IMPORTANT</a>: if you are REPLACING an existing 1002Sendmail installation with Postfix, you may need to keep the old 1003sendmail program running for some time in order to flush the mail 1004queue. </p> 1005 1006<ul> 1007 1008<li> <p> Some systems implement a mail switch mechanism where 1009different MTAs (Postfix, Sendmail, etc.) can be installed at the 1010same time, while only one of them is actually being used. Examples 1011of such switching mechanisms are the FreeBSD mailwrapper(8) or the 1012Linux mail switch. In this case you should try to "flip" the switch 1013to "Postfix" before installing Postfix. </p> 1014 1015<li> <p> If your system has no mail switch mechanism, execute the 1016following commands (your sendmail, newaliases and mailq programs 1017may be in a different place): </p> 1018 1019<pre> 1020# mv /usr/sbin/sendmail /usr/sbin/sendmail.OFF 1021# mv /usr/bin/newaliases /usr/bin/newaliases.OFF 1022# mv /usr/bin/mailq /usr/bin/mailq.OFF 1023# chmod 755 /usr/sbin/sendmail.OFF /usr/bin/newaliases.OFF \ 1024 /usr/bin/mailq.OFF 1025</pre> 1026 1027</ul> 1028 1029<h3>6.2 - Create account and groups</h3> 1030 1031<p> Before you install Postfix for the first time you need to 1032create an account and a group:</p> 1033 1034<ul> 1035 1036<li> <p> Create a user account "postfix" with a user id and group 1037id that are not used by any other user account. Preferably, this 1038is an account that no-one can log into. The account does not need 1039an executable login shell, and needs no existing home directory. 1040My password and group file entries look like this: </p> 1041 1042<blockquote> 1043<pre> 1044/etc/passwd: 1045 postfix:*:12345:12345:postfix:/no/where:/no/shell 1046 1047/etc/group: 1048 postfix:*:12345: 1049</pre> 1050</blockquote> 1051 1052<p> Note: there should be no whitespace before "postfix:". </p> 1053 1054<li> <p> Create a group "postdrop" with a group id that is not used 1055by any other user account. Not even by the postfix user account. 1056My group file entry looks like: 1057 1058<blockquote> 1059<pre> 1060/etc/group: 1061 postdrop:*:54321: 1062</pre> 1063</blockquote> 1064 1065<p> Note: there should be no whitespace before "postdrop:". </p> 1066 1067</ul> 1068 1069<h3>6.3 - Install Postfix</h3> 1070 1071<p> To install or upgrade Postfix from compiled source code, run 1072one of the following commands as the super-user:</p> 1073 1074<blockquote> 1075<pre> 1076# make install (interactive version, first time install) 1077 1078# make upgrade (non-interactive version, for upgrades) 1079</pre> 1080</blockquote> 1081 1082<ul> 1083 1084<li> <p> The interactive version ("make install") asks for pathnames 1085for Postfix data and program files, and stores your preferences in 1086the <a href="postconf.5.html">main.cf</a> file. <b> If you don't want Postfix to overwrite 1087non-Postfix "sendmail", "mailq" and "newaliases" files, specify 1088pathnames that end in ".postfix"</b>. </p> 1089 1090<li> <p> The non-interactive version ("make upgrade") needs the 1091/etc/postfix/<a href="postconf.5.html">main.cf</a> file from a previous installation. If the file 1092does not exist, use interactive installation ("make install") 1093instead. </p> 1094 1095<li> <p> If you specify name=value arguments on the "make install" 1096or "make upgrade" command line, then these will take precedence 1097over compiled-in default settings or <a href="postconf.5.html">main.cf</a> settings. </p> 1098 1099<p> The command "make install/upgrade name=value ..." will replace 1100the string MAIL_VERSION at the end of a configuration parameter 1101value with the Postfix release version. Do not try to specify 1102something like $<a href="postconf.5.html#mail_version">mail_version</a> on this command line. This produces 1103inconsistent results with different versions of the make(1) command. 1104</p> 1105 1106</ul> 1107 1108<h3>6.4 - Configure Postfix</h3> 1109 1110<p> Proceed to the section on how you wish to run Postfix on 1111your particular machine: </p> 1112 1113<ul> 1114 1115<li> <p> <a href="#send_only">Send</a> mail only, without changing 1116an existing Sendmail installation (section 7). </p> 1117 1118<li> <p> <a href="#send_receive">Send and receive</a> mail via a 1119virtual host interface, still without any change to an existing 1120Sendmail installation (section 8). </p> 1121 1122<li> <p> Run Postfix <a href="#replace">instead of</a> Sendmail 1123(section 9). </p> 1124 1125</ul> 1126 1127<h2><a name="send_only">7 - Configuring Postfix to send mail 1128only</a></h2> 1129 1130<p> If you are going to use Postfix to send mail only, there is no 1131need to change your existing sendmail setup. Instead, set up your 1132mail user agent so that it calls the Postfix sendmail program 1133directly. </p> 1134 1135<p> Follow the instructions in the "<a href="#mandatory">Mandatory 1136configuration file edits</a>" in section 10, and review the "<a 1137href="#hamlet">To chroot or not to chroot</a>" text in section 113811. </p> 1139 1140<p> You MUST comment out the "smtp inet" entry in /etc/postfix/<a href="master.5.html">master.cf</a>, 1141in order to avoid conflicts with the real sendmail. Put a "#" 1142character in front of the line that defines the smtpd service: </p> 1143 1144<blockquote> 1145<pre> 1146/etc/postfix/<a href="master.5.html">master.cf</a>: 1147 #smtp inet n - n - - smtpd 1148</pre> 1149</blockquote> 1150 1151<p> Start the Postfix system: </p> 1152 1153<blockquote> 1154<pre> 1155# postfix start 1156</pre> 1157</blockquote> 1158 1159<p> or, if you feel nostalgic, use the Postfix sendmail command: </p> 1160 1161<blockquote> 1162<pre> 1163# sendmail -bd -qwhatever 1164</pre> 1165</blockquote> 1166 1167<p> and watch your maillog file for any error messages. The pathname 1168is /var/log/maillog, /var/log/mail, /var/log/syslog, or something 1169else. Typically, the pathname is defined in the /etc/syslog.conf 1170file. </p> 1171 1172<blockquote> 1173<pre> 1174$ egrep '(reject|warning|error|fatal|panic):' /some/log/file 1175</pre> 1176</blockquote> 1177 1178<p> Note: the most important error message is logged first. Later 1179messages are not as useful. </p> 1180 1181<p> In order to inspect the mail queue, use one of the following 1182commands: </p> 1183 1184<blockquote> 1185<pre> 1186$ mailq 1187 1188$ sendmail -bp 1189 1190$ postqueue -p 1191</pre> 1192</blockquote> 1193 1194<p> See also the "<a href="#care">Care and feeding</a>" section 12 1195below. </p> 1196 1197<h2><a name="send_receive">8 - Configuring Postfix to send and 1198receive mail via virtual interface</a></h2> 1199 1200<p> Alternatively, you can use the Postfix system to send AND 1201receive mail while leaving your Sendmail setup intact, by running 1202Postfix on a virtual interface address. Simply configure your mail 1203user agent to directly invoke the Postfix sendmail program. </p> 1204 1205<p> To create a virtual network interface address, study your 1206system ifconfig manual page. The command syntax could be any 1207of: </p> 1208 1209<blockquote> 1210<pre> 1211# <b>ifconfig le0:1 <address> netmask <mask> up</b> 1212# <b>ifconfig en0 alias <address> netmask 255.255.255.255</b> 1213</pre> 1214</blockquote> 1215 1216<p> In the /etc/postfix/<a href="postconf.5.html">main.cf</a> file, I would specify </p> 1217 1218<blockquote> 1219<pre> 1220/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1221 <a href="postconf.5.html#myhostname">myhostname</a> = virtual.host.tld 1222 <a href="postconf.5.html#inet_interfaces">inet_interfaces</a> = $<a href="postconf.5.html#myhostname">myhostname</a> 1223 <a href="postconf.5.html#mydestination">mydestination</a> = $<a href="postconf.5.html#myhostname">myhostname</a> 1224</pre> 1225</blockquote> 1226 1227<p> Follow the instructions in the "<a href="#mandatory">Mandatory 1228configuration file edits</a>" in section 10, and review the "<a 1229name="#hamlet">To chroot or not to chroot</a>" text in section 123011. </p> 1231 1232<p> Start the Postfix system: </p> 1233 1234<blockquote> 1235<pre> 1236# postfix start 1237</pre> 1238</blockquote> 1239 1240<p> or, if you feel nostalgic, use the Postfix sendmail command: </p> 1241 1242<blockquote> 1243<pre> 1244# sendmail -bd -qwhatever 1245</pre> 1246</blockquote> 1247 1248<p> and watch your maillog file for any error messages. The pathname 1249is /var/log/maillog, /var/log/mail, /var/log/syslog, or something 1250else. Typically, the pathname is defined in the /etc/syslog.conf 1251file. </p> 1252 1253<blockquote> 1254<pre> 1255$ egrep '(reject|warning|error|fatal|panic):' /some/log/file 1256</pre> 1257</blockquote> 1258 1259<p> Note: the most important error message is logged first. Later 1260messages are not as useful. </p> 1261 1262<p> In order to inspect the mail queue, use one of the following 1263commands: </p> 1264 1265<blockquote> 1266<pre> 1267$ mailq 1268 1269$ sendmail -bp 1270 1271$ postqueue -p 1272</pre> 1273</blockquote> 1274 1275<p> See also the "<a href="#care">Care and feeding</a>" section 12 1276below. </p> 1277 1278<h2><a name="replace">9 - Running Postfix instead of Sendmail</a></h2> 1279 1280<p> Prior to installing Postfix you should <a href="#save">save</a> 1281any existing sendmail program files as described in section 6. Be 1282sure to keep the old sendmail running for at least a couple days 1283to flush any unsent mail. To do so, stop the sendmail daemon and 1284restart it as: </p> 1285 1286<blockquote> 1287<pre> 1288# /usr/sbin/sendmail.OFF -q 1289</pre> 1290</blockquote> 1291 1292<p> Note: this is old sendmail syntax. Newer versions use separate 1293processes for mail submission and for running the queue. </p> 1294 1295<p> After you have visited the "<a href="#mandatory">Mandatory 1296configuration file edits</a>" section below, you can start the 1297Postfix system with: </p> 1298 1299<blockquote> 1300<pre> 1301# postfix start 1302</pre> 1303</blockquote> 1304 1305<p> or, if you feel nostalgic, use the Postfix sendmail command: </p> 1306 1307<blockquote> 1308<pre> 1309# sendmail -bd -qwhatever 1310</pre> 1311</blockquote> 1312 1313<p> and watch your maillog file for any error messages. The pathname 1314is /var/log/maillog, /var/log/mail, /var/log/syslog, or something 1315else. Typically, the pathname is defined in the /etc/syslog.conf 1316file. </p> 1317 1318<blockquote> 1319<pre> 1320$ egrep '(reject|warning|error|fatal|panic):' /some/log/file 1321</pre> 1322</blockquote> 1323 1324<p> Note: the most important error message is logged first. Later 1325messages are not as useful. </p> 1326 1327<p> In order to inspect the mail queue, use one of the following 1328commands: </p> 1329 1330<blockquote> 1331<pre> 1332$ mailq 1333 1334$ sendmail -bp 1335 1336$ postqueue -p 1337</pre> 1338</blockquote> 1339 1340<p> See also the "<a href="#care">Care and feeding</a>" section 12 1341below. </p> 1342 1343<h2><a name="mandatory">10 - Mandatory configuration file edits</a></h2> 1344 1345<p> Note: the material covered in this section is covered in more 1346detail in the <a href="BASIC_CONFIGURATION_README.html">BASIC_CONFIGURATION_README</a> document. The information 1347presented below is targeted at experienced system administrators. 1348</p> 1349 1350<h3>10.1 - Postfix configuration files</h3> 1351 1352<p> By default, Postfix configuration files are in /etc/postfix. 1353The two most important files are <a href="postconf.5.html">main.cf</a> and <a href="master.5.html">master.cf</a>; these files 1354must be owned by root. Giving someone else write permission to 1355<a href="postconf.5.html">main.cf</a> or <a href="master.5.html">master.cf</a> (or to their parent directories) means giving 1356root privileges to that person. </p> 1357 1358<p> In /etc/postfix/<a href="postconf.5.html">main.cf</a>, you will have to set up a minimal number 1359of configuration parameters. Postfix configuration parameters 1360resemble shell variables, with two important differences: the first 1361one is that Postfix does not know about quotes like the UNIX shell 1362does.</p> 1363 1364<p> You specify a configuration parameter as: </p> 1365 1366<blockquote> 1367<pre> 1368/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1369 parameter = value 1370</pre> 1371</blockquote> 1372 1373<p> and you use it by putting a "$" character in front of its name: </p> 1374 1375<blockquote> 1376<pre> 1377/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1378 other_parameter = $parameter 1379</pre> 1380</blockquote> 1381 1382<p> You can use $parameter before it is given a value (that is the 1383second main difference with UNIX shell variables). The Postfix 1384configuration language uses lazy evaluation, and does not look at 1385a parameter value until it is needed at runtime. </p> 1386 1387<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, 1388execute the following command in order to refresh a running mail 1389system: </p> 1390 1391<blockquote> 1392<pre> 1393# postfix reload 1394</pre> 1395</blockquote> 1396 1397<h3>10.2 - Default domain for unqualified addresses</h3> 1398 1399<p> First of all, you must specify what domain will be appended to an 1400unqualified address (i.e. an address without @domain.tld). The 1401"<a href="postconf.5.html#myorigin">myorigin</a>" parameter defaults to the local hostname, but that is 1402probably OK only for very small sites. </p> 1403 1404<p> Some examples (use only one): </p> 1405 1406<blockquote> 1407<pre> 1408/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1409 <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>") 1410 <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>") 1411</pre> 1412</blockquote> 1413 1414<h3>10.3 - What domains to receive locally</h3> 1415 1416<p> Next you need to specify what mail addresses Postfix should deliver 1417locally. </p> 1418 1419<p> Some examples (use only one): </p> 1420 1421<blockquote> 1422<pre> 1423/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1424 <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 1425 <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> 1426 <a href="postconf.5.html#mydestination">mydestination</a> = $<a href="postconf.5.html#myhostname">myhostname</a> 1427</pre> 1428</blockquote> 1429 1430<p>The first example is appropriate for a workstation, the second 1431is appropriate for the mailserver for an entire domain. The third 1432example should be used when running on a virtual host interface.</p> 1433 1434<h3>10.4 - Proxy/NAT interface addresses </h3> 1435 1436<p> The <a href="postconf.5.html#proxy_interfaces">proxy_interfaces</a> parameter specifies all network addresses 1437that Postfix receives mail on by way of a proxy or network address 1438translation unit. You may specify symbolic hostnames instead of 1439network addresses. </p> 1440 1441<p> IMPORTANT: You must specify your proxy/NAT external addresses 1442when your system is a backup MX host for other domains, otherwise 1443mail delivery loops will happen when the primary MX host is down. 1444</p> 1445 1446<p> Example: host behind NAT box running a backup MX host. </p> 1447 1448<blockquote> 1449<pre> 1450/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1451 <a href="postconf.5.html#proxy_interfaces">proxy_interfaces</a> = 1.2.3.4 (the proxy/NAT external network address) 1452</pre> 1453</blockquote> 1454 1455<h3>10.5 - What local clients to relay mail from </h3> 1456 1457<p> If your machine is on an open network then you must specify 1458what client IP addresses are authorized to relay their mail through 1459your machine into the Internet. The default setting includes all 1460subnetworks that the machine is attached to. This may give relay 1461permission to too many clients. My own settings are: </p> 1462 1463<blockquote> 1464<pre> 1465/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1466 <a href="postconf.5.html#mynetworks">mynetworks</a> = 168.100.189.0/28, 127.0.0.0/8 1467</pre> 1468</blockquote> 1469 1470<h3>10.6 - What relay destinations to accept from strangers </h3> 1471 1472<p> If your machine is on an open network then you must also specify 1473whether Postfix will forward mail from strangers. The default 1474setting will forward mail to all domains (and subdomains of) what 1475is listed in $<a href="postconf.5.html#mydestination">mydestination</a>. This may give relay permission for 1476too many destinations. Recommended settings (use only one): </p> 1477 1478<blockquote> 1479<pre> 1480/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1481 <a href="postconf.5.html#relay_domains">relay_domains</a> = (do not forward mail from strangers) 1482 <a href="postconf.5.html#relay_domains">relay_domains</a> = $<a href="postconf.5.html#mydomain">mydomain</a> (my domain and subdomains) 1483 <a href="postconf.5.html#relay_domains">relay_domains</a> = $<a href="postconf.5.html#mydomain">mydomain</a>, other.domain.tld, ... 1484</pre> 1485</blockquote> 1486 1487<h3>10.7 - Optional: configure a smart host for remote delivery</h3> 1488 1489<p> If you're behind a firewall, you should set up a <a href="postconf.5.html#relayhost">relayhost</a>. If 1490you can, specify the organizational domain name so that Postfix 1491can use DNS lookups, and so that it can fall back to a secondary 1492MX host when the primary MX host is down. Otherwise just specify 1493a hard-coded hostname. </p> 1494 1495<p> Some examples (use only one): </p> 1496 1497<blockquote> 1498<pre> 1499/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1500 <a href="postconf.5.html#relayhost">relayhost</a> = $<a href="postconf.5.html#mydomain">mydomain</a> 1501 <a href="postconf.5.html#relayhost">relayhost</a> = [mail.$<a href="postconf.5.html#mydomain">mydomain</a>] 1502</pre> 1503</blockquote> 1504 1505<p> The form enclosed with <tt>[]</tt> eliminates DNS MX lookups. </p> 1506 1507<p> By default, the SMTP client will do DNS lookups even when you 1508specify a <a href="postconf.5.html#relayhost">relay host</a>. If your machine has no access to a DNS server, 1509turn off SMTP client DNS lookups like this: </p> 1510 1511<blockquote> 1512<pre> 1513/etc/postfix/<a href="postconf.5.html">main.cf</a>: 1514 <a href="postconf.5.html#disable_dns_lookups">disable_dns_lookups</a> = yes 1515</pre> 1516</blockquote> 1517 1518<p> The <a href="STANDARD_CONFIGURATION_README.html">STANDARD_CONFIGURATION_README</a> file has more hints and tips for 1519firewalled and/or dial-up networks. </p> 1520 1521<h3>10.8 - Create the aliases database</h3> 1522 1523<p> Postfix uses a Sendmail-compatible <a href="aliases.5.html">aliases(5)</a> table to redirect 1524mail for <a href="local.8.html">local(8)</a> recipients. Typically, this information is kept 1525in two files: in a text file /etc/aliases and in an indexed file 1526/etc/aliases.db. The command "postconf <a href="postconf.5.html#alias_maps">alias_maps</a>" will tell you 1527the exact location of the text file. </p> 1528 1529<p> First, be sure to update the text file with aliases for root, 1530postmaster and "postfix" that forward mail to a real person. Postfix 1531has a sample aliases file /etc/postfix/aliases that you can adapt 1532to local conditions. </p> 1533 1534<blockquote> 1535<pre> 1536/etc/aliases: 1537 root: you 1538 postmaster: root 1539 postfix: root 1540 bin: root 1541 <i>etcetera...</i> 1542</pre> 1543</blockquote> 1544 1545<p> Note: there should be no whitespace before the ":". </p> 1546 1547<p> Finally, build the indexed aliases file with one of the 1548following commands: </p> 1549 1550<blockquote> 1551<pre> 1552# newaliases 1553# sendmail -bi 1554</pre> 1555</blockquote> 1556 1557<h2><a name="hamlet">11 - To chroot or not to chroot</a></h2> 1558 1559<p> Postfix daemon processes can be configured (via <a href="master.5.html">master.cf</a>) to 1560run in a chroot jail. The processes run at a fixed low privilege 1561and with access only to the Postfix queue directories (/var/spool/postfix). 1562This provides a significant barrier against intrusion. The barrier 1563is not impenetrable, but every little bit helps. </p> 1564 1565<p> With the exception of Postfix daemons that deliver mail locally 1566and/or that execute non-Postfix commands, every Postfix daemon can 1567run chrooted. </p> 1568 1569<p> Sites with high security requirements should consider to chroot 1570all daemons that talk to the network: the <a href="smtp.8.html">smtp(8)</a> and <a href="smtpd.8.html">smtpd(8)</a> 1571processes, and perhaps also the <a href="lmtp.8.html">lmtp(8)</a> client. The author's own 1572porcupine.org mail server runs all daemons chrooted that can be 1573chrooted. </p> 1574 1575<p> The default /etc/postfix/<a href="master.5.html">master.cf</a> file specifies that no 1576Postfix daemon runs chrooted. In order to enable chroot operation, 1577edit the file /etc/postfix/<a href="master.5.html">master.cf</a>. Instructions are in the file. 1578</p> 1579 1580<p> Note that a chrooted daemon resolves all filenames relative to 1581the Postfix queue directory (/var/spool/postfix). For successful 1582use of a chroot jail, most UNIX systems require you to bring in 1583some files or device nodes. The examples/chroot-setup directory 1584in the source code distribution has a collection of scripts that 1585help you set up Postfix chroot environments on different operating 1586systems. </p> 1587 1588<p> Additionally, you almost certainly need to configure syslogd 1589so that it listens on a socket inside the Postfix queue directory. 1590Examples for specific systems: </p> 1591 1592<dl> 1593 1594<dt> FreeBSD: </dt> 1595 1596<dd> <pre> 1597# mkdir -p /var/spool/postfix/var/run 1598# syslogd -l /var/spool/postfix/var/run/log 1599</pre> </dd> 1600 1601<dt> Linux, OpenBSD: </dt> 1602 1603<dd> <pre> 1604# mkdir -p /var/spool/postfix/dev 1605# syslogd -a /var/spool/postfix/dev/log 1606</pre> </dd> 1607 1608</dl> 1609 1610<h2><a name="care">12 - Care and feeding of the Postfix system</a></h2> 1611 1612<p> Postfix daemon processes run in the background, and log problems 1613and normal activity to the syslog daemon. The names of logfiles 1614are specified in /etc/syslog.conf. At the very least you need 1615something like: </p> 1616 1617<blockquote> 1618<pre> 1619/etc/syslog.conf: 1620 mail.err /dev/console 1621 mail.debug /var/log/maillog 1622</pre> 1623</blockquote> 1624 1625<p> IMPORTANT: the syslogd will not create files. You must create 1626them before (re)starting syslogd. </p> 1627 1628<p> IMPORTANT: on Linux you need to put a "-" character before 1629the pathname, e.g., -/var/log/maillog, otherwise the syslogd 1630will use more system resources than Postfix does. </p> 1631 1632<p> Hopefully, the number of problems will be small, but it is a good 1633idea to run every night before the syslog files are rotated: </p> 1634 1635<blockquote> 1636<pre> 1637# postfix check 1638# egrep '(reject|warning|error|fatal|panic):' /some/log/file 1639</pre> 1640</blockquote> 1641 1642<ul> 1643 1644<li> <p> The first line (postfix check) causes Postfix to report 1645file permission/ownership discrepancies. </p> 1646 1647<li> <p> The second line looks for problem reports from the mail 1648software, and reports how effective the relay and junk mail access 1649blocks are. This may produce a lot of output. You will want to 1650apply some postprocessing to eliminate uninteresting information. 1651</p> 1652 1653</ul> 1654 1655<p> The <a href="DEBUG_README.html#logging"> DEBUG_README </a> 1656document describes the meaning of the "warning" etc. labels in 1657Postfix logging. </p> 1658 1659</body> 1660 1661</html> 1662