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