xref: /netbsd-src/external/ibm-public/postfix/dist/proto/BASIC_CONFIGURATION_README.html (revision 413d532bcc3f62d122e56d92e13ac64825a40baf)
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 default is to
258authorize all clients in the IP subnetworks that the local machine
259is attached to. </p>
260
261<p> Postfix can also be configured to relay mail from "mobile"
262clients that send mail from outside an authorized network block.
263This is explained in the SASL_README and TLS_README documents. </p>
264
265<p> IMPORTANT: If your machine is connected to a wide area network
266then your default mynetworks setting may be too friendly. </p>
267
268<p> Examples (specify only one of the following): </p>
269
270<blockquote>
271<pre>
272/etc/postfix/main.cf:
273    mynetworks_style = subnet  (default: authorize subnetworks)
274    mynetworks_style = host    (safe: authorize local machine only)
275    mynetworks = 127.0.0.0/8   (safe: authorize local machine only)
276    mynetworks = 127.0.0.0/8 168.100.189.2/32 (authorize local machine)
277</pre>
278</blockquote>
279
280<p> You can specify the trusted networks in the main.cf file, or
281you can let Postfix do the work for you. The default is to let
282Postfix do the work. The result depends on the mynetworks_style
283parameter value.
284
285<ul>
286
287<li> <p> Specify "mynetworks_style = host" when Postfix should
288forward mail from only the local machine. </p>
289
290<li> <p> Specify "mynetworks_style = subnet" (the default) when
291Postfix should forward mail from SMTP clients in the same IP
292subnetworks as the local machine.  On Linux, this works correctly
293only with interfaces specified with the "ifconfig" command. </p>
294
295<li> <p> Specify "mynetworks_style = class" when Postfix should
296forward mail from SMTP clients in the same IP class A/B/C networks
297as the local machine. Don't do this with a dialup site - it would
298cause Postfix to "trust" your entire provider's network. Instead,
299specify an explicit mynetworks list by hand, as described below.
300</p>
301
302</ul>
303
304<p> Alternatively, you can specify the mynetworks list by hand,
305in which case Postfix ignores the mynetworks_style setting.
306To specify the list of trusted networks by hand, specify network
307blocks in CIDR (network/mask) notation, for example: </p>
308
309<blockquote>
310<pre>
311/etc/postfix/main.cf:
312    mynetworks = 168.100.189.0/28, 127.0.0.0/8
313</pre>
314</blockquote>
315
316<p> You can also specify the absolute pathname of a pattern file instead
317of listing the patterns in the main.cf file. </p>
318
319<h2> <a name="relay_to"> What destinations to relay mail to </a> </h2>
320
321<p> By default, Postfix will forward mail from strangers (clients outside
322authorized networks) to authorized remote destinations only.
323Authorized remote
324destinations are defined with the relay_domains configuration
325parameter.  The default is to authorize all domains (and subdomains)
326of the domains listed with the mydestination parameter.  </p>
327
328<p> Examples (specify only one of the following): </p>
329
330<blockquote>
331<pre>
332/etc/postfix/main.cf:
333    relay_domains = $mydestination (default)
334    relay_domains =           (safe: never forward mail from strangers)
335    relay_domains = $mydomain (forward mail to my domain and subdomains)
336</pre>
337</blockquote>
338
339<h2> <a name="relayhost"> What delivery method: direct or
340indirect </a> </h2>
341
342<p> By default, Postfix tries to deliver mail directly to the
343Internet. Depending on your local conditions this may not be possible
344or desirable.  For example, your system may be turned off outside
345office hours, it may be behind a firewall, or it may be connected
346via a provider who does not allow direct mail to the Internet.  In
347those cases you need to configure Postfix to deliver mail indirectly
348via a relay host. </p>
349
350<p> Examples (specify only one of the following): </p>
351
352<blockquote>
353<pre>
354/etc/postfix/main.cf:
355    relayhost =                   (default: direct delivery to Internet)
356    relayhost = $mydomain         (deliver via local mailhub)
357    relayhost = [mail.$mydomain]  (deliver via local mailhub)
358    relayhost = [mail.isp.tld]    (deliver via provider mailhub)
359</pre>
360</blockquote>
361
362<p> The form enclosed with <tt>[]</tt> eliminates DNS MX lookups.
363Don't worry if you don't know what that means. Just be sure to
364specify the <tt>[]</tt> around the mailhub hostname that your ISP
365gave to you, otherwise mail may be mis-delivered. </p>
366
367<p> The STANDARD_CONFIGURATION_README file has more hints and tips
368for firewalled and/or dial-up networks. </p>
369
370<h2> <a name="notify"> What trouble to report to the postmaster</a> </h2>
371
372<p> You should set up a postmaster alias in the aliases(5) table
373that directs mail to a human person.  The postmaster address is
374required to exist, so that people can report mail delivery problems.
375While you're updating the aliases(5) table, be sure to direct mail
376for the super-user to a human person too. </p>
377
378<blockquote>
379<pre>
380/etc/aliases:
381    postmaster: you
382    root: you
383</pre>
384</blockquote>
385
386<p> Execute the command "newaliases" after changing the aliases
387file.  Instead of /etc/aliases, your alias file may be located
388elsewhere.  Use the command "postconf alias_maps" to find out.</p>
389
390<p> The Postfix system reports problems to the postmaster alias.
391You may not be interested in all types of trouble reports, so this
392reporting mechanism is configurable. The default is to report only
393serious problems (resource, software) to postmaster:  </p>
394
395<p> Default setting: </p>
396
397<blockquote>
398<pre>
399/etc/postfix/main.cf:
400    notify_classes = resource, software
401</pre>
402</blockquote>
403
404<p> The meaning of the classes is as follows: </p>
405
406<blockquote>
407
408<dl>
409
410<dt> bounce </dt> <dd>  Inform the postmaster of undeliverable
411mail.  Either send the postmaster a copy of undeliverable mail that
412is returned to the sender, or send a transcript of the SMTP session
413when Postfix rejected mail.  For privacy reasons, the postmaster
414copy of undeliverable mail is truncated after the original message
415headers.  This implies "2bounce" (see below).  See also the
416luser_relay feature. The notification is sent to the address
417specified with the bounce_notice_recipient configuration parameter
418(default:  postmaster).  </dd>
419
420<dt> 2bounce </dt> <dd> When Postfix is unable to return undeliverable
421mail to the sender, send it to the postmaster instead (without
422truncating the message after the primary headers). The notification
423is sent to the address specified with the 2bounce_notice_recipient
424configuration parameter (default:  postmaster).  </dd>
425
426<dt> delay </dt> <dd> Inform the postmaster of delayed mail.  In
427this case, the postmaster receives message headers only.  The
428notification is sent to the address specified with the
429delay_notice_recipient configuration parameter (default:  postmaster).
430</dd>
431
432<dt> policy </dt> <dd> Inform the postmaster of client requests
433that were rejected because of (UCE) policy restrictions.  The
434postmaster receives a transcript of the SMTP session. The notification
435is sent to the address specified with the error_notice_recipient
436configuration parameter (default:  postmaster).  </dd>
437
438<dt> protocol </dt> <dd> Inform the postmaster of protocol errors
439(client or server side) or attempts by a client to execute
440unimplemented commands. The postmaster receives a transcript of
441the SMTP session. The notification is sent to the address specified
442with the error_notice_recipient configuration parameter (default:
443postmaster). </dd>
444
445<dt> resource </dt> <dd> Inform the postmaster of mail not delivered
446due to resource problems (for example, queue file write errors).
447The notification is sent to the address specified with the
448error_notice_recipient configuration parameter (default:  postmaster).
449</dd>
450
451<dt> software </dt> <dd> Inform the postmaster of mail not delivered
452due to software problems. The notification is sent to the address
453specified with the error_notice_recipient configuration parameter
454(default:  postmaster). </dd>
455
456</dl>
457
458</blockquote>
459
460<h2><a name="proxy_interfaces"> Proxy/NAT external network
461addresses</a> </h2>
462
463<p> Some mail servers are connected to the Internet via a network
464address translator (NAT) or proxy. This means that systems on the
465Internet connect to the address of the NAT or proxy, instead of
466connecting to the network address of the mail server. The NAT or
467proxy forwards the connection to the network address of the mail
468server, but Postfix does not know this.  </p>
469
470<p> If you run a Postfix server behind a proxy or NAT, you need to
471configure the proxy_interfaces parameter and specify all the external
472proxy or NAT addresses that Postfix receives mail on. You may
473specify symbolic hostnames instead of network addresses.  </p>
474
475<p> IMPORTANT: You must specify your proxy/NAT external addresses
476when your system is a backup MX host for other domains, otherwise
477mail delivery loops will happen when the primary MX host is down.
478</p>
479
480<p> Example: host behind NAT box running a backup MX host. </p>
481
482<blockquote>
483<pre>
484/etc/postfix/main.cf:
485    proxy_interfaces = 1.2.3.4 (the proxy/NAT external network address)
486</pre>
487</blockquote>
488
489<h2> <a name="syslog_howto"> What you need to know about
490Postfix logging </a> </h2>
491
492<p> Postfix daemon processes run in the background, and log problems
493and normal activity to the syslog daemon. The syslogd process sorts
494events by class and severity, and appends them to logfiles. The
495logging classes, levels and logfile names are usually specified in
496/etc/syslog.conf. At the very least you need something like:  </p>
497
498<blockquote>
499<pre>
500/etc/syslog.conf:
501    mail.err                                    /dev/console
502    mail.debug                                  /var/log/maillog
503</pre>
504</blockquote>
505
506<p> After changing the syslog.conf file, send a "HUP" signal to
507the syslogd process.  </p>
508
509<p> IMPORTANT: many syslogd implementations will not create files.
510You must create files before (re)starting syslogd. </p>
511
512<p> IMPORTANT: on Linux you need to put a "-" character before the
513pathname, e.g., -/var/log/maillog, otherwise the syslogd process
514will use more system resources than Postfix. </p>
515
516<p> Hopefully, the number of problems will be small, but it is a good
517idea to run every night before the syslog files are rotated: </p>
518
519<blockquote>
520<pre>
521# postfix check
522# egrep '(reject|warning|error|fatal|panic):' /some/log/file
523</pre>
524</blockquote>
525
526<ul>
527
528<li> <p> The first line (postfix check) causes Postfix to report
529file permission/ownership discrepancies. </p>
530
531<li> <p> The second line looks for problem reports from the mail
532software, and reports how effective the relay and junk mail access
533blocks are.  This may produce a lot of output.  You will want to
534apply some postprocessing to eliminate uninteresting information.
535</p>
536
537</ul>
538
539<p> The <a href="DEBUG_README.html#logging"> DEBUG_README </a>
540document describes the meaning of the "warning" etc. labels in
541Postfix logging. </p>
542
543<h2> <a name="chroot_setup"> Running Postfix daemon processes
544chrooted </a> </h2>
545
546<p> Postfix daemon processes can be configured (via the master.cf
547file) to run in a chroot jail.  The processes run at a fixed low
548privilege and with file system access limited to the Postfix queue
549directories (/var/spool/postfix).  This provides a significant
550barrier against intrusion. The barrier is not impenetrable (chroot
551limits file system access only), but every little bit helps.</p>
552
553<p>With the exception of Postfix daemons that deliver mail locally
554and/or that execute non-Postfix commands, every Postfix daemon can
555run chrooted.</p>
556
557<p>Sites with high security requirements should consider to chroot
558all daemons that talk to the network: the smtp(8) and smtpd(8)
559processes, and perhaps also the lmtp(8) client. The author's own
560porcupine.org mail server runs all daemons chrooted that can be
561chrooted.  </p>
562
563<p>The default /etc/postfix/master.cf file specifies that no Postfix
564daemon runs chrooted. In order to enable chroot operation, edit
565the file /etc/postfix/master.cf, and follow instructions in the
566file.  When you're finished, execute "postfix reload" to make the
567change effective. </p>
568
569<p>Note that a chrooted daemon resolves all filenames relative to
570the Postfix queue directory (/var/spool/postfix). For successful
571use of a chroot jail, most UNIX systems require you to bring in
572some files or device nodes. The examples/chroot-setup directory in
573the source code distribution has a collection of scripts that help
574you set up Postfix chroot environments on different operating
575systems.</p>
576
577<p> Additionally, you almost certainly need to configure syslogd
578so that it listens on a socket inside the Postfix queue directory.
579Examples of syslogd command line options that achieve this for
580specific systems: </p>
581
582<p> FreeBSD: <tt>syslogd -l /var/spool/postfix/var/run/log</tt> </p>
583
584<p> Linux, OpenBSD: <tt>syslogd -a /var/spool/postfix/dev/log</tt> </p>
585
586<h2><a name="myhostname"> My own hostname </a> </h2>
587
588<p> The myhostname parameter specifies the fully-qualified domain
589name of the machine running the Postfix system.   $myhostname
590appears as the default value in many other Postfix configuration
591parameters. </p>
592
593<p> By default, myhostname is set to the local machine name.  If
594your local machine name is not in fully-qualified domain name form,
595or if you run Postfix on a virtual interface, you will have to
596specify the fully-qualified domain name that the mail system should
597use. </p>
598
599<p> Alternatively, if you specify mydomain in main.cf, then Postfix
600will use its value to generate a fully-qualified default value
601for the myhostname parameter. </p>
602
603<p> Examples (specify only one of the following): </p>
604
605<blockquote>
606<pre>
607/etc/postfix/main.cf:
608    myhostname = host.local.domain (machine name is not FQDN)
609    myhostname = host.virtual.domain (virtual interface)
610    myhostname = virtual.domain (virtual interface)
611</pre>
612</blockquote>
613
614<h2><a name="mydomain"> My own domain name</a> </h2>
615
616<p> The mydomain parameter specifies the parent domain of
617$myhostname.  By default, it is derived from  $myhostname
618by stripping off the first part (unless the result would be a
619top-level domain). </p>
620
621<p> Conversely, if you specify mydomain in main.cf, then Postfix
622will use its value to generate a fully-qualified default value
623for the myhostname parameter. </p>
624
625<p> Examples (specify only one of the following): </p>
626
627<blockquote>
628<pre>
629/etc/postfix/main.cf:
630    mydomain = local.domain
631    mydomain = virtual.domain (virtual interface)
632</pre>
633</blockquote>
634
635<h2><a name="inet_interfaces">My own network addresses</a> </h2>
636
637<p>The inet_interfaces parameter specifies all network interface
638addresses that the Postfix system should listen on; mail addressed
639to "user@[network address]" will be delivered locally,
640as if it is addressed to a domain listed in  $mydestination.</p>
641
642<p> You can override the inet_interfaces setting in the Postfix
643master.cf file by prepending an IP address to a server name. </p>
644
645<p> The default is to listen on all active interfaces.  If you run
646mailers on virtual interfaces, you will have to specify what
647interfaces to listen on.  </p>
648
649<p> IMPORTANT: If you run MTAs on virtual interfaces you must
650specify explicit inet_interfaces values for the MTA that receives
651mail for the machine itself:  this MTA should never listen on the
652virtual interfaces or you would have a mailer loop when a virtual
653MTA is down.  </p>
654
655<p> Example: default setting. </p>
656
657<blockquote>
658<pre>
659/etc/postfix/main.cf:
660    inet_interfaces = all
661</pre>
662</blockquote>
663
664<p> Example: host running one or more virtual mailers. For
665each Postfix instance, specify only one of the following. </p>
666
667<blockquote>
668<pre>
669/etc/postfix/main.cf:
670    inet_interfaces = virtual.host.tld         (virtual Postfix)
671    inet_interfaces = $myhostname localhost... (non-virtual Postfix)
672</pre>
673</blockquote>
674
675<p> Note: you need to stop and start Postfix after changing this
676parameter.  </p>
677
678</body>
679
680</html>
681