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