xref: /netbsd-src/external/ibm-public/postfix/dist/proto/BASIC_CONFIGURATION_README.html (revision 181254a7b1bdde6873432bffef2d2decc4b5c22f)
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 Basic Configuration </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 Basic Configuration </h1>
17
18<hr>
19
20<h2> Introduction </h2>
21
22<p> Postfix has several hundred configuration parameters that are
23controlled via the main.cf file.  Fortunately, all parameters have
24sensible default values.  In many cases, you need to configure only
25two or three parameters before you can start to play with the mail
26system. Here's a quick introduction to the syntax:  </p>
27
28<ul>
29
30<li> <p> <a href="#syntax">Postfix configuration files</a></p>
31
32</ul>
33
34<p> The text below assumes that you already have Postfix installed
35on the system, either by compiling the source code yourself (as
36described in the INSTALL file) or by installing an already compiled
37version.  </p>
38
39<p> This document covers basic Postfix configuration. Information
40about how to configure Postfix for specific applications such as
41mailhub, firewall or dial-up client can be found in the
42STANDARD_CONFIGURATION_README file. But don't go there until you
43already have covered the material presented below.  </p>
44
45<p> The first parameters of interest specify the machine's identity
46and role in the network. </p>
47
48<ul>
49
50<li> <p> <a href="#myorigin"> What domain name to use in outbound mail </a> </p>
51
52<li> <p> <a href="#mydestination"> What domains to receive mail for </a> </p>
53
54<li> <p> <a href="#relay_from"> What clients to relay mail from </a> </p>
55
56<li> <p> <a href="#relay_to"> What destinations to relay mail to </a> </p>
57
58<li> <p> <a href="#relayhost"> What delivery method: direct or
59indirect </a> </p>
60
61</ul>
62
63<p> The default values for many other configuration parameters are
64derived from just these. </p>
65
66<p> The next parameter of interest controls the amount of mail sent
67to the local postmaster: </p>
68
69<ul>
70
71<li> <p> <a href="#notify"> What trouble to report to the postmaster
72</a> </p>
73
74</ul>
75
76<p> Be sure to set the following correctly if you're behind a proxy or
77network address translator, and you are running a backup MX host
78for some other domain: </p>
79
80<ul>
81
82<li> <p> <a href="#proxy_interfaces"> Proxy/NAT external network
83addresses </a> </p>
84
85</ul>
86
87<p>  Postfix daemon processes run in the background, and log problems
88and normal activity to the syslog daemon. Here are a few things
89that you need to be aware of: </p>
90
91<ul>
92
93<li> <p> <a href="#syslog_howto"> What you need to know about
94Postfix logging </a> </p>
95
96</ul>
97
98<p> If your machine has unusual security requirements you may
99want to run Postfix daemon processes inside a chroot environment. </p>
100
101<ul>
102
103<li> <p> <a href="#chroot_setup"> Running Postfix daemon processes
104chrooted </a> </p>
105
106</ul>
107<p> If you run Postfix on a virtual network interface, or if your
108machine runs other mailers on virtual interfaces, you'll have to
109look at the other parameters listed here as well: </p>
110
111<ul>
112
113<li> <p> <a href="#myhostname"> My own hostname </a> </p>
114
115<li> <p> <a href="#mydomain"> My own domain name </a> </p>
116
117<li> <p> <a href="#inet_interfaces"> My own network addresses </a> </p>
118
119</ul>
120
121<h2> <a name="syntax">Postfix configuration files</a></h2>
122
123<p> By default, Postfix configuration files are in /etc/postfix.
124The two most important files are main.cf and master.cf; these files
125must be owned by root.  Giving someone else write permission to
126main.cf or master.cf (or to their parent directories) means giving
127root privileges to that person. </p>
128
129<p> In /etc/postfix/main.cf you will have to set up a minimal number
130of configuration parameters.  Postfix configuration parameters
131resemble shell variables, with two important differences: the first
132one is that Postfix does not know about quotes like the UNIX shell
133does.</p>
134
135<p> You specify a configuration parameter as: </p>
136
137<blockquote>
138<pre>
139/etc/postfix/main.cf:
140    parameter = value
141</pre>
142</blockquote>
143
144<p> and you use it by putting a "$" character in front of its name: </p>
145
146<blockquote>
147<pre>
148/etc/postfix/main.cf:
149    other_parameter = $parameter
150</pre>
151</blockquote>
152
153<p> You can use $parameter before it is given a value (that is the
154second main difference with UNIX shell variables). The Postfix
155configuration language uses lazy evaluation, and does not look at
156a parameter value until it is needed at runtime.  </p>
157
158<p> Postfix uses database files for access control, address rewriting
159and other purposes. The DATABASE_README file gives an introduction
160to how Postfix works with Berkeley DB, LDAP or SQL and other types.
161Here is a common example of how Postfix invokes a database: </p>
162
163<blockquote>
164<pre>
165/etc/postfix/main.cf:
166    virtual_alias_maps = hash:/etc/postfix/virtual
167</pre>
168</blockquote>
169
170<p> Whenever you make a change to the main.cf or master.cf file,
171execute the following command as root in order to refresh a running
172mail system: </p>
173
174<blockquote>
175<pre>
176# postfix reload
177</pre>
178</blockquote>
179
180<h2> <a name="myorigin"> What domain name to use in outbound mail </a> </h2>
181
182<p> The myorigin parameter specifies the domain that appears in
183mail that is posted on this machine. The default is to use the
184local machine name, $myhostname, which defaults to the name of the
185machine. Unless you are running a really small site, you probably
186want to change that into $mydomain, which defaults to the parent
187domain of the machine name. </p>
188
189<p> For the sake of consistency between sender and recipient addresses,
190myorigin also specifies the domain name that is appended
191to an unqualified recipient address. </p>
192
193<p> Examples (specify only one of the following): </p>
194
195<blockquote>
196<pre>
197/etc/postfix/main.cf:
198    myorigin = $myhostname (default: send mail as "user@$myhostname")
199    myorigin = $mydomain   (probably desirable: "user@$mydomain")
200</pre>
201</blockquote>
202
203<h2><a name="mydestination"> What domains to receive mail for </a>
204</h2>
205
206<p> The mydestination parameter specifies what domains this
207machine will deliver locally, instead of forwarding to another
208machine. The default is to receive mail for the machine itself.
209See the VIRTUAL_README file for how to configure Postfix for
210hosted domains. </p>
211
212<p> You can specify zero or more domain names, "/file/name" patterns
213and/or "type:table" lookup tables (such as hash:, btree:, nis:, ldap:,
214or mysql:), separated by whitespace and/or commas.  A "/file/name"
215pattern is replaced by its contents; "type:table" requests that a
216table lookup is done and merely tests for existence: the lookup
217result is ignored.  </p>
218
219<p> IMPORTANT: If your machine is a mail server for its entire
220domain, you must list $mydomain as well.  </p>
221
222<p> Example 1: default setting. </p>
223
224<blockquote>
225<pre>
226/etc/postfix/main.cf:
227    mydestination = $myhostname localhost.$mydomain localhost
228</pre>
229</blockquote>
230
231<p> Example 2: domain-wide mail server. </p>
232
233<blockquote>
234<pre>
235/etc/postfix/main.cf:
236    mydestination = $myhostname localhost.$mydomain localhost $mydomain
237</pre>
238</blockquote>
239
240<p> Example 3: host with multiple DNS A records. </p>
241
242<blockquote>
243<pre>
244/etc/postfix/main.cf:
245    mydestination = $myhostname localhost.$mydomain localhost
246        www.$mydomain ftp.$mydomain
247</pre>
248</blockquote>
249
250<p> Caution: in order to avoid mail delivery loops, you must list all
251hostnames of the machine, including $myhostname, and localhost.$mydomain. </p>
252
253<h2> <a name="relay_from"> What clients to relay mail from </a> </h2>
254
255<p> By default, Postfix will forward mail from clients in authorized
256network blocks to any destination.  Authorized networks are defined
257with the mynetworks configuration parameter. The current default is to
258authorize the local machine only. Prior to Postfix 3.0, the default
259was to authorize all clients in the IP subnetworks that the local
260machine is attached to. </p>
261
262<p> Postfix can also be configured to relay mail from "mobile"
263clients that send mail from outside an authorized network block.
264This is explained in the SASL_README and TLS_README documents. </p>
265
266<p> IMPORTANT: If your machine is connected to a wide area network
267then the "mynetworks_style = host" setting may be too friendly. </p>
268
269<p> Examples (specify only one of the following): </p>
270
271<blockquote>
272<pre>
273/etc/postfix/main.cf:
274    mynetworks_style = subnet  (not safe on a wide area network)
275    mynetworks_style = host    (authorize local machine only)
276    mynetworks = 127.0.0.0/8   (authorize local machine only)
277    mynetworks = 127.0.0.0/8 168.100.189.2/32 (authorize local machine)
278    mynetworks = 127.0.0.0/8 168.100.189.2/28 (authorize local networks)
279</pre>
280</blockquote>
281
282<p> You can specify the trusted networks in the main.cf file, or
283you can let Postfix do the work for you. The default is to let
284Postfix do the work. The result depends on the mynetworks_style
285parameter value.
286
287<ul>
288
289<li> <p> Specify "mynetworks_style = host" when Postfix should
290forward mail from only the local machine. </p>
291
292<li> <p> Specify "mynetworks_style = subnet" (the default) when
293Postfix should forward mail from SMTP clients in the same IP
294subnetworks as the local machine.  On Linux, this works correctly
295only with interfaces specified with the "ifconfig" command. </p>
296
297<li> <p> Specify "mynetworks_style = class" when Postfix should
298forward mail from SMTP clients in the same IP class A/B/C networks
299as the local machine. Don't do this with a dialup site - it would
300cause Postfix to "trust" your entire provider's network. Instead,
301specify an explicit mynetworks list by hand, as described below.
302</p>
303
304</ul>
305
306<p> Alternatively, you can specify the mynetworks list by hand,
307in which case Postfix ignores the mynetworks_style setting.
308To specify the list of trusted networks by hand, specify network
309blocks in CIDR (network/mask) notation, for example: </p>
310
311<blockquote>
312<pre>
313/etc/postfix/main.cf:
314    mynetworks = 168.100.189.0/28, 127.0.0.0/8
315</pre>
316</blockquote>
317
318<p> You can also specify the absolute pathname of a pattern file instead
319of listing the patterns in the main.cf file. </p>
320
321<h2> <a name="relay_to"> What destinations to relay mail to </a> </h2>
322
323<p> By default, Postfix will forward mail from strangers (clients outside
324authorized networks) to authorized remote destinations only.
325Authorized remote
326destinations are defined with the relay_domains configuration
327parameter.  The default is to authorize all domains (and subdomains)
328of the domains listed with the mydestination parameter.  </p>
329
330<p> Examples (specify only one of the following): </p>
331
332<blockquote>
333<pre>
334/etc/postfix/main.cf:
335    relay_domains = $mydestination (default)
336    relay_domains =           (safe: never forward mail from strangers)
337    relay_domains = $mydomain (forward mail to my domain and subdomains)
338</pre>
339</blockquote>
340
341<h2> <a name="relayhost"> What delivery method: direct or
342indirect </a> </h2>
343
344<p> By default, Postfix tries to deliver mail directly to the
345Internet. Depending on your local conditions this may not be possible
346or desirable.  For example, your system may be turned off outside
347office hours, it may be behind a firewall, or it may be connected
348via a provider who does not allow direct mail to the Internet.  In
349those cases you need to configure Postfix to deliver mail indirectly
350via a relay host. </p>
351
352<p> Examples (specify only one of the following): </p>
353
354<blockquote>
355<pre>
356/etc/postfix/main.cf:
357    relayhost =                   (default: direct delivery to Internet)
358    relayhost = $mydomain         (deliver via local mailhub)
359    relayhost = [mail.$mydomain]  (deliver via local mailhub)
360    relayhost = [mail.isp.tld]    (deliver via provider mailhub)
361</pre>
362</blockquote>
363
364<p> The form enclosed with <tt>[]</tt> eliminates DNS MX lookups.
365Don't worry if you don't know what that means. Just be sure to
366specify the <tt>[]</tt> around the mailhub hostname that your ISP
367gave to you, otherwise mail may be mis-delivered. </p>
368
369<p> The STANDARD_CONFIGURATION_README file has more hints and tips
370for firewalled and/or dial-up networks. </p>
371
372<h2> <a name="notify"> What trouble to report to the postmaster</a> </h2>
373
374<p> You should set up a postmaster alias in the aliases(5) table
375that directs mail to a human person.  The postmaster address is
376required to exist, so that people can report mail delivery problems.
377While you're updating the aliases(5) table, be sure to direct mail
378for the super-user to a human person too. </p>
379
380<blockquote>
381<pre>
382/etc/aliases:
383    postmaster: you
384    root: you
385</pre>
386</blockquote>
387
388<p> Execute the command "newaliases" after changing the aliases
389file.  Instead of /etc/aliases, your alias file may be located
390elsewhere.  Use the command "postconf alias_maps" to find out.</p>
391
392<p> The Postfix system reports problems to the postmaster alias.
393You may not be interested in all types of trouble reports, so this
394reporting mechanism is configurable. The default is to report only
395serious problems (resource, software) to postmaster:  </p>
396
397<p> Default setting: </p>
398
399<blockquote>
400<pre>
401/etc/postfix/main.cf:
402    notify_classes = resource, software
403</pre>
404</blockquote>
405
406<p> The meaning of the classes is as follows: </p>
407
408<blockquote>
409
410<dl>
411
412<dt> bounce </dt> <dd>  Inform the postmaster of undeliverable
413mail.  Either send the postmaster a copy of undeliverable mail that
414is returned to the sender, or send a transcript of the SMTP session
415when Postfix rejected mail.  For privacy reasons, the postmaster
416copy of undeliverable mail is truncated after the original message
417headers.  This implies "2bounce" (see below).  See also the
418luser_relay feature. The notification is sent to the address
419specified with the bounce_notice_recipient configuration parameter
420(default:  postmaster).  </dd>
421
422<dt> 2bounce </dt> <dd> When Postfix is unable to return undeliverable
423mail to the sender, send it to the postmaster instead (without
424truncating the message after the primary headers). The notification
425is sent to the address specified with the 2bounce_notice_recipient
426configuration parameter (default:  postmaster).  </dd>
427
428<dt> delay </dt> <dd> Inform the postmaster of delayed mail.  In
429this case, the postmaster receives message headers only.  The
430notification is sent to the address specified with the
431delay_notice_recipient configuration parameter (default:  postmaster).
432</dd>
433
434<dt> policy </dt> <dd> Inform the postmaster of client requests
435that were rejected because of (UCE) policy restrictions.  The
436postmaster receives a transcript of the SMTP session. The notification
437is sent to the address specified with the error_notice_recipient
438configuration parameter (default:  postmaster).  </dd>
439
440<dt> protocol </dt> <dd> Inform the postmaster of protocol errors
441(client or server side) or attempts by a client to execute
442unimplemented commands. The postmaster receives a transcript of
443the SMTP session. The notification is sent to the address specified
444with the error_notice_recipient configuration parameter (default:
445postmaster). </dd>
446
447<dt> resource </dt> <dd> Inform the postmaster of mail not delivered
448due to resource problems (for example, queue file write errors).
449The notification is sent to the address specified with the
450error_notice_recipient configuration parameter (default:  postmaster).
451</dd>
452
453<dt> software </dt> <dd> Inform the postmaster of mail not delivered
454due to software problems. The notification is sent to the address
455specified with the error_notice_recipient configuration parameter
456(default:  postmaster). </dd>
457
458</dl>
459
460</blockquote>
461
462<h2><a name="proxy_interfaces"> Proxy/NAT external network
463addresses</a> </h2>
464
465<p> Some mail servers are connected to the Internet via a network
466address translator (NAT) or proxy. This means that systems on the
467Internet connect to the address of the NAT or proxy, instead of
468connecting to the network address of the mail server. The NAT or
469proxy forwards the connection to the network address of the mail
470server, but Postfix does not know this.  </p>
471
472<p> If you run a Postfix server behind a proxy or NAT, you need to
473configure the proxy_interfaces parameter and specify all the external
474proxy or NAT addresses that Postfix receives mail on. You may
475specify symbolic hostnames instead of network addresses.  </p>
476
477<p> IMPORTANT: You must specify your proxy/NAT external addresses
478when your system is a backup MX host for other domains, otherwise
479mail delivery loops will happen when the primary MX host is down.
480</p>
481
482<p> Example: host behind NAT box running a backup MX host. </p>
483
484<blockquote>
485<pre>
486/etc/postfix/main.cf:
487    proxy_interfaces = 1.2.3.4 (the proxy/NAT external network address)
488</pre>
489</blockquote>
490
491<h2> <a name="syslog_howto"> What you need to know about
492Postfix logging </a> </h2>
493
494<p> Postfix daemon processes run in the background, and log problems
495and normal activity to the syslog daemon. The syslogd process sorts
496events by class and severity, and appends them to logfiles. The
497logging classes, levels and logfile names are usually specified in
498/etc/syslog.conf. At the very least you need something like:  </p>
499
500<blockquote>
501<pre>
502/etc/syslog.conf:
503    mail.err                                    /dev/console
504    mail.debug                                  /var/log/maillog
505</pre>
506</blockquote>
507
508<p> After changing the syslog.conf file, send a "HUP" signal to
509the syslogd process.  </p>
510
511<p> IMPORTANT: many syslogd implementations will not create files.
512You must create files before (re)starting syslogd. </p>
513
514<p> IMPORTANT: on Linux you need to put a "-" character before the
515pathname, e.g., -/var/log/maillog, otherwise the syslogd process
516will use more system resources than Postfix. </p>
517
518<p> Hopefully, the number of problems will be small, but it is a good
519idea to run every night before the syslog files are rotated: </p>
520
521<blockquote>
522<pre>
523# postfix check
524# egrep '(reject|warning|error|fatal|panic):' /some/log/file
525</pre>
526</blockquote>
527
528<ul>
529
530<li> <p> The first line (postfix check) causes Postfix to report
531file permission/ownership discrepancies. </p>
532
533<li> <p> The second line looks for problem reports from the mail
534software, and reports how effective the relay and junk mail access
535blocks are.  This may produce a lot of output.  You will want to
536apply some postprocessing to eliminate uninteresting information.
537</p>
538
539</ul>
540
541<p> The <a href="DEBUG_README.html#logging"> DEBUG_README </a>
542document describes the meaning of the "warning" etc. labels in
543Postfix logging. </p>
544
545<h2> <a name="chroot_setup"> Running Postfix daemon processes
546chrooted </a> </h2>
547
548<p> Postfix daemon processes can be configured (via the master.cf
549file) to run in a chroot jail.  The processes run at a fixed low
550privilege and with file system access limited to the Postfix queue
551directories (/var/spool/postfix).  This provides a significant
552barrier against intrusion. The barrier is not impenetrable (chroot
553limits file system access only), but every little bit helps.</p>
554
555<p>With the exception of Postfix daemons that deliver mail locally
556and/or that execute non-Postfix commands, every Postfix daemon can
557run chrooted.</p>
558
559<p>Sites with high security requirements should consider to chroot
560all daemons that talk to the network: the smtp(8) and smtpd(8)
561processes, and perhaps also the lmtp(8) client. The author's own
562porcupine.org mail server runs all daemons chrooted that can be
563chrooted.  </p>
564
565<p>The default /etc/postfix/master.cf file specifies that no Postfix
566daemon runs chrooted. In order to enable chroot operation, edit
567the file /etc/postfix/master.cf, and follow instructions in the
568file.  When you're finished, execute "postfix reload" to make the
569change effective. </p>
570
571<p>Note that a chrooted daemon resolves all filenames relative to
572the Postfix queue directory (/var/spool/postfix). For successful
573use of a chroot jail, most UNIX systems require you to bring in
574some files or device nodes. The examples/chroot-setup directory in
575the source code distribution has a collection of scripts that help
576you set up Postfix chroot environments on different operating
577systems.</p>
578
579<p> Additionally, you almost certainly need to configure syslogd
580so that it listens on a socket inside the Postfix queue directory.
581Examples of syslogd command line options that achieve this for
582specific systems: </p>
583
584<p> FreeBSD: <tt>syslogd -l /var/spool/postfix/var/run/log</tt> </p>
585
586<p> Linux, OpenBSD: <tt>syslogd -a /var/spool/postfix/dev/log</tt> </p>
587
588<h2><a name="myhostname"> My own hostname </a> </h2>
589
590<p> The myhostname parameter specifies the fully-qualified domain
591name of the machine running the Postfix system.   $myhostname
592appears as the default value in many other Postfix configuration
593parameters. </p>
594
595<p> By default, myhostname is set to the local machine name.  If
596your local machine name is not in fully-qualified domain name form,
597or if you run Postfix on a virtual interface, you will have to
598specify the fully-qualified domain name that the mail system should
599use. </p>
600
601<p> Alternatively, if you specify mydomain in main.cf, then Postfix
602will use its value to generate a fully-qualified default value
603for the myhostname parameter. </p>
604
605<p> Examples (specify only one of the following): </p>
606
607<blockquote>
608<pre>
609/etc/postfix/main.cf:
610    myhostname = host.local.domain (machine name is not FQDN)
611    myhostname = host.virtual.domain (virtual interface)
612    myhostname = virtual.domain (virtual interface)
613</pre>
614</blockquote>
615
616<h2><a name="mydomain"> My own domain name</a> </h2>
617
618<p> The mydomain parameter specifies the parent domain of
619$myhostname.  By default, it is derived from  $myhostname
620by stripping off the first part (unless the result would be a
621top-level domain). </p>
622
623<p> Conversely, if you specify mydomain in main.cf, then Postfix
624will use its value to generate a fully-qualified default value
625for the myhostname parameter. </p>
626
627<p> Examples (specify only one of the following): </p>
628
629<blockquote>
630<pre>
631/etc/postfix/main.cf:
632    mydomain = local.domain
633    mydomain = virtual.domain (virtual interface)
634</pre>
635</blockquote>
636
637<h2><a name="inet_interfaces">My own network addresses</a> </h2>
638
639<p>The inet_interfaces parameter specifies all network interface
640addresses that the Postfix system should listen on; mail addressed
641to "user@[network address]" will be delivered locally,
642as if it is addressed to a domain listed in  $mydestination.</p>
643
644<p> You can override the inet_interfaces setting in the Postfix
645master.cf file by prepending an IP address to a server name. </p>
646
647<p> The default is to listen on all active interfaces.  If you run
648mailers on virtual interfaces, you will have to specify what
649interfaces to listen on.  </p>
650
651<p> IMPORTANT: If you run MTAs on virtual interfaces you must
652specify explicit inet_interfaces values for the MTA that receives
653mail for the machine itself:  this MTA should never listen on the
654virtual interfaces or you would have a mailer loop when a virtual
655MTA is down.  </p>
656
657<p> Example: default setting. </p>
658
659<blockquote>
660<pre>
661/etc/postfix/main.cf:
662    inet_interfaces = all
663</pre>
664</blockquote>
665
666<p> Example: host running one or more virtual mailers. For
667each Postfix instance, specify only one of the following. </p>
668
669<blockquote>
670<pre>
671/etc/postfix/main.cf:
672    inet_interfaces = virtual.host.tld         (virtual Postfix)
673    inet_interfaces = $myhostname localhost... (non-virtual Postfix)
674</pre>
675</blockquote>
676
677<p> Note: you need to stop and start Postfix after changing this
678parameter.  </p>
679
680</body>
681
682</html>
683