1 P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx B
\bBa
\bas
\bsi
\bic
\bc C
\bCo
\bon
\bnf
\bfi
\big
\bgu
\bur
\bra
\bat
\bti
\bio
\bon
\bn
3 -------------------------------------------------------------------------------
5 I
\bIn
\bnt
\btr
\bro
\bod
\bdu
\buc
\bct
\bti
\bio
\bon
\bn
7 Postfix has several hundred configuration parameters that are controlled via
8 the main.cf file. Fortunately, all parameters have sensible default values. In
9 many cases, you need to configure only two or three parameters before you can
10 start to play with the mail system. Here's a quick introduction to the syntax:
12 * Postfix configuration files
14 The text below assumes that you already have Postfix installed on the system,
15 either by compiling the source code yourself (as described in the INSTALL file)
16 or by installing an already compiled version.
18 This document covers basic Postfix configuration. Information about how to
19 configure Postfix for specific applications such as mailhub, firewall or dial-
20 up client can be found in the STANDARD_CONFIGURATION_README file. But don't go
21 there until you already have covered the material presented below.
23 The first parameters of interest specify the machine's identity and role in the
26 * What domain name to use in outbound mail
28 * What domains to receive mail for
30 * What clients to relay mail from
32 * What destinations to relay mail to
34 * What delivery method: direct or indirect
36 The default values for many other configuration parameters are derived from
39 The next parameter of interest controls the amount of mail sent to the local
42 * What trouble to report to the postmaster
44 Be sure to set the following correctly if you're behind a proxy or network
45 address translator, and you are running a backup MX host for some other domain:
47 * Proxy/NAT external network addresses
49 Postfix daemon processes run in the background, and log problems and normal
50 activity to the syslog daemon. Here are a few things that you need to be aware
53 * What you need to know about Postfix logging
55 If your machine has unusual security requirements you may want to run Postfix
56 daemon processes inside a chroot environment.
58 * Running Postfix daemon processes chrooted
60 If you run Postfix on a virtual network interface, or if your machine runs
61 other mailers on virtual interfaces, you'll have to look at the other
62 parameters listed here as well:
68 * My own network addresses
70 P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx c
\bco
\bon
\bnf
\bfi
\big
\bgu
\bur
\bra
\bat
\bti
\bio
\bon
\bn f
\bfi
\bil
\ble
\bes
\bs
72 By default, Postfix configuration files are in /etc/postfix. The two most
73 important files are main.cf and master.cf; these files must be owned by root.
74 Giving someone else write permission to main.cf or master.cf (or to their
75 parent directories) means giving root privileges to that person.
77 In /etc/postfix/main.cf you will have to set up a minimal number of
78 configuration parameters. Postfix configuration parameters resemble shell
79 variables, with two important differences: the first one is that Postfix does
80 not know about quotes like the UNIX shell does.
82 You specify a configuration parameter as:
87 and you use it by putting a "$" character in front of its name:
90 other_parameter = $parameter
92 You can use $parameter before it is given a value (that is the second main
93 difference with UNIX shell variables). The Postfix configuration language uses
94 lazy evaluation, and does not look at a parameter value until it is needed at
97 Postfix uses database files for access control, address rewriting and other
98 purposes. The DATABASE_README file gives an introduction to how Postfix works
99 with Berkeley DB, LDAP or SQL and other types. Here is a common example of how
100 Postfix invokes a database:
102 /etc/postfix/main.cf:
103 virtual_alias_maps = hash:/etc/postfix/virtual
105 Whenever you make a change to the main.cf or master.cf file, execute the
106 following command as root in order to refresh a running mail system:
110 W
\bWh
\bha
\bat
\bt d
\bdo
\bom
\bma
\bai
\bin
\bn n
\bna
\bam
\bme
\be t
\bto
\bo u
\bus
\bse
\be i
\bin
\bn o
\bou
\but
\btb
\bbo
\bou
\bun
\bnd
\bd m
\bma
\bai
\bil
\bl
112 The myorigin parameter specifies the domain that appears in mail that is posted
113 on this machine. The default is to use the local machine name, $myhostname,
114 which defaults to the name of the machine. Unless you are running a really
115 small site, you probably want to change that into $mydomain, which defaults to
116 the parent domain of the machine name.
118 For the sake of consistency between sender and recipient addresses, myorigin
119 also specifies the domain name that is appended to an unqualified recipient
122 Examples (specify only one of the following):
124 /etc/postfix/main.cf:
125 myorigin = $myhostname (default: send mail as "user@$myhostname")
126 myorigin = $mydomain (probably desirable: "user@$mydomain")
128 W
\bWh
\bha
\bat
\bt d
\bdo
\bom
\bma
\bai
\bin
\bns
\bs t
\bto
\bo r
\bre
\bec
\bce
\bei
\biv
\bve
\be m
\bma
\bai
\bil
\bl f
\bfo
\bor
\br
130 The mydestination parameter specifies what domains this machine will deliver
131 locally, instead of forwarding to another machine. The default is to receive
132 mail for the machine itself. See the VIRTUAL_README file for how to configure
133 Postfix for hosted domains.
135 You can specify zero or more domain names, "/file/name" patterns and/or "type:
136 table" lookup tables (such as hash:, btree:, nis:, ldap:, or mysql:), separated
137 by whitespace and/or commas. A "/file/name" pattern is replaced by its
138 contents; "type:table" requests that a table lookup is done and merely tests
139 for existence: the lookup result is ignored.
141 IMPORTANT: If your machine is a mail server for its entire domain, you must
142 list $mydomain as well.
144 Example 1: default setting.
146 /etc/postfix/main.cf:
147 mydestination = $myhostname localhost.$mydomain localhost
149 Example 2: domain-wide mail server.
151 /etc/postfix/main.cf:
152 mydestination = $myhostname localhost.$mydomain localhost $mydomain
154 Example 3: host with multiple DNS A records.
156 /etc/postfix/main.cf:
157 mydestination = $myhostname localhost.$mydomain localhost
158 www.$mydomain ftp.$mydomain
160 Caution: in order to avoid mail delivery loops, you must list all hostnames of
161 the machine, including $myhostname, and localhost.$mydomain.
163 W
\bWh
\bha
\bat
\bt c
\bcl
\bli
\bie
\ben
\bnt
\bts
\bs t
\bto
\bo r
\bre
\bel
\bla
\bay
\by m
\bma
\bai
\bil
\bl f
\bfr
\bro
\bom
\bm
165 By default, Postfix will forward mail from clients in authorized network blocks
166 to any destination. Authorized networks are defined with the mynetworks
167 configuration parameter. The default is to authorize all clients in the IP
168 subnetworks that the local machine is attached to.
170 IMPORTANT: If your machine is connected to a wide area network then your
171 default mynetworks setting may be too friendly.
173 Examples (specify only one of the following):
175 /etc/postfix/main.cf:
176 mynetworks_style = subnet (default: authorize subnetworks)
177 mynetworks_style = host (safe: authorize local machine only)
178 mynetworks = 127.0.0.0/8 (safe: authorize local machine only)
179 mynetworks = 127.0.0.0/8 168.100.189.2/32 (authorize local machine)
181 You can specify the trusted networks in the main.cf file, or you can let
182 Postfix do the work for you. The default is to let Postfix do the work. The
183 result depends on the mynetworks_style parameter value.
185 * Specify "mynetworks_style = host" when Postfix should forward mail from
186 only the local machine.
188 * Specify "mynetworks_style = subnet" (the default) when Postfix should
189 forward mail from SMTP clients in the same IP subnetworks as the local
190 machine. On Linux, this works correctly only with interfaces specified with
191 the "ifconfig" command.
193 * Specify "mynetworks_style = class" when Postfix should forward mail from
194 SMTP clients in the same IP class A/B/C networks as the local machine.
195 Don't do this with a dialup site - it would cause Postfix to "trust" your
196 entire provider's network. Instead, specify an explicit mynetworks list by
197 hand, as described below.
199 Alternatively, you can specify the mynetworks list by hand, in which case
200 Postfix ignores the mynetworks_style setting. To specify the list of trusted
201 networks by hand, specify network blocks in CIDR (network/mask) notation, for
204 /etc/postfix/main.cf:
205 mynetworks = 168.100.189.0/28, 127.0.0.0/8
207 You can also specify the absolute pathname of a pattern file instead of listing
208 the patterns in the main.cf file.
210 W
\bWh
\bha
\bat
\bt d
\bde
\bes
\bst
\bti
\bin
\bna
\bat
\bti
\bio
\bon
\bns
\bs t
\bto
\bo r
\bre
\bel
\bla
\bay
\by m
\bma
\bai
\bil
\bl t
\bto
\bo
212 By default, Postfix will forward mail from strangers (clients outside
213 authorized networks) to authorized remote destinations only. Authorized remote
214 destinations are defined with the relay_domains configuration parameter. The
215 default is to authorize all domains (and subdomains) of the domains listed with
216 the mydestination parameter.
218 Examples (specify only one of the following):
220 /etc/postfix/main.cf:
221 relay_domains = $mydestination (default)
222 relay_domains = (safe: never forward mail from strangers)
223 relay_domains = $mydomain (forward mail to my domain and subdomains)
225 W
\bWh
\bha
\bat
\bt d
\bde
\bel
\bli
\biv
\bve
\ber
\bry
\by m
\bme
\bet
\bth
\bho
\bod
\bd:
\b: d
\bdi
\bir
\bre
\bec
\bct
\bt o
\bor
\br i
\bin
\bnd
\bdi
\bir
\bre
\bec
\bct
\bt
227 By default, Postfix tries to deliver mail directly to the Internet. Depending
228 on your local conditions this may not be possible or desirable. For example,
229 your system may be turned off outside office hours, it may be behind a
230 firewall, or it may be connected via a provider who does not allow direct mail
231 to the Internet. In those cases you need to configure Postfix to deliver mail
232 indirectly via a relay host.
234 Examples (specify only one of the following):
236 /etc/postfix/main.cf:
237 relayhost = (default: direct delivery to Internet)
238 relayhost = $mydomain (deliver via local mailhub)
239 relayhost = [mail.$mydomain] (deliver via local mailhub)
240 relayhost = [mail.isp.tld] (deliver via provider mailhub)
242 The form enclosed with [] eliminates DNS MX lookups. Don't worry if you don't
243 know what that means. Just be sure to specify the [] around the mailhub
244 hostname that your ISP gave to you, otherwise mail may be mis-delivered.
246 The STANDARD_CONFIGURATION_README file has more hints and tips for firewalled
247 and/or dial-up networks.
249 W
\bWh
\bha
\bat
\bt t
\btr
\bro
\bou
\bub
\bbl
\ble
\be t
\bto
\bo r
\bre
\bep
\bpo
\bor
\brt
\bt t
\bto
\bo t
\bth
\bhe
\be p
\bpo
\bos
\bst
\btm
\bma
\bas
\bst
\bte
\ber
\br
251 You should set up a postmaster alias in the aliases(5) table that directs mail
252 to a human person. The postmaster address is required to exist, so that people
253 can report mail delivery problems. While you're updating the aliases(5) table,
254 be sure to direct mail for the super-user to a human person too.
260 Execute the command "newaliases" after changing the aliases file. Instead of /
261 etc/aliases, your alias file may be located elsewhere. Use the command
262 "postconf alias_maps" to find out.
264 The Postfix system reports problems to the postmaster alias. You may not be
265 interested in all types of trouble reports, so this reporting mechanism is
266 configurable. The default is to report only serious problems (resource,
267 software) to postmaster:
271 /etc/postfix/main.cf:
272 notify_classes = resource, software
274 The meaning of the classes is as follows:
277 Inform the postmaster of undeliverable mail. Either send the postmaster
278 a copy of undeliverable mail that is returned to the sender, or send a
279 transcript of the SMTP session when Postfix rejected mail. For privacy
280 reasons, the postmaster copy of undeliverable mail is truncated after
281 the original message headers. This implies "2bounce" (see below). See
282 also the luser_relay feature. The notification is sent to the address
283 specified with the bounce_notice_recipient configuration parameter
284 (default: postmaster).
286 When Postfix is unable to return undeliverable mail to the sender, send
287 it to the postmaster instead (without truncating the message after the
288 primary headers). The notification is sent to the address specified
289 with the 2bounce_notice_recipient configuration parameter (default:
292 Inform the postmaster of delayed mail. In this case, the postmaster
293 receives message headers only. The notification is sent to the address
294 specified with the delay_notice_recipient configuration parameter
295 (default: postmaster).
297 Inform the postmaster of client requests that were rejected because of
298 (UCE) policy restrictions. The postmaster receives a transcript of the
299 SMTP session. The notification is sent to the address specified with
300 the error_notice_recipient configuration parameter (default:
303 Inform the postmaster of protocol errors (client or server side) or
304 attempts by a client to execute unimplemented commands. The postmaster
305 receives a transcript of the SMTP session. The notification is sent to
306 the address specified with the error_notice_recipient configuration
307 parameter (default: postmaster).
309 Inform the postmaster of mail not delivered due to resource problems
310 (for example, queue file write errors). The notification is sent to the
311 address specified with the error_notice_recipient configuration
312 parameter (default: postmaster).
314 Inform the postmaster of mail not delivered due to software problems.
315 The notification is sent to the address specified with the
316 error_notice_recipient configuration parameter (default: postmaster).
318 P
\bPr
\bro
\box
\bxy
\by/
\b/N
\bNA
\bAT
\bT e
\bex
\bxt
\bte
\ber
\brn
\bna
\bal
\bl n
\bne
\bet
\btw
\bwo
\bor
\brk
\bk a
\bad
\bdd
\bdr
\bre
\bes
\bss
\bse
\bes
\bs
320 Some mail servers are connected to the Internet via a network address
321 translator (NAT) or proxy. This means that systems on the Internet connect to
322 the address of the NAT or proxy, instead of connecting to the network address
323 of the mail server. The NAT or proxy forwards the connection to the network
324 address of the mail server, but Postfix does not know this.
326 If you run a Postfix server behind a proxy or NAT, you need to configure the
327 proxy_interfaces parameter and specify all the external proxy or NAT addresses
328 that Postfix receives mail on. You may specify symbolic hostnames instead of
331 IMPORTANT: You must specify your proxy/NAT external addresses when your system
332 is a backup MX host for other domains, otherwise mail delivery loops will
333 happen when the primary MX host is down.
335 Example: host behind NAT box running a backup MX host.
337 /etc/postfix/main.cf:
338 proxy_interfaces = 1.2.3.4 (the proxy/NAT external network address)
340 W
\bWh
\bha
\bat
\bt y
\byo
\bou
\bu n
\bne
\bee
\bed
\bd t
\bto
\bo k
\bkn
\bno
\bow
\bw a
\bab
\bbo
\bou
\but
\bt P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx l
\blo
\bog
\bgg
\bgi
\bin
\bng
\bg
342 Postfix daemon processes run in the background, and log problems and normal
343 activity to the syslog daemon. The syslogd process sorts events by class and
344 severity, and appends them to logfiles. The logging classes, levels and logfile
345 names are usually specified in /etc/syslog.conf. At the very least you need
349 mail.err /dev/console
350 mail.debug /var/log/maillog
352 After changing the syslog.conf file, send a "HUP" signal to the syslogd
355 IMPORTANT: many syslogd implementations will not create files. You must create
356 files before (re)starting syslogd.
358 IMPORTANT: on Linux you need to put a "-" character before the pathname, e.g.,
359 -/var/log/maillog, otherwise the syslogd process will use more system resources
362 Hopefully, the number of problems will be small, but it is a good idea to run
363 every night before the syslog files are rotated:
366 # egrep '(reject|warning|error|fatal|panic):' /some/log/file
368 * The first line (postfix check) causes Postfix to report file permission/
369 ownership discrepancies.
371 * The second line looks for problem reports from the mail software, and
372 reports how effective the relay and junk mail access blocks are. This may
373 produce a lot of output. You will want to apply some postprocessing to
374 eliminate uninteresting information.
376 The DEBUG_README document describes the meaning of the "warning" etc. labels in
379 R
\bRu
\bun
\bnn
\bni
\bin
\bng
\bg P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx d
\bda
\bae
\bem
\bmo
\bon
\bn p
\bpr
\bro
\boc
\bce
\bes
\bss
\bse
\bes
\bs c
\bch
\bhr
\bro
\boo
\bot
\bte
\bed
\bd
381 Postfix daemon processes can be configured (via the master.cf file) to run in a
382 chroot jail. The processes run at a fixed low privilege and with file system
383 access limited to the Postfix queue directories (/var/spool/postfix). This
384 provides a significant barrier against intrusion. The barrier is not
385 impenetrable (chroot limits file system access only), but every little bit
388 With the exception of Postfix daemons that deliver mail locally and/or that
389 execute non-Postfix commands, every Postfix daemon can run chrooted.
391 Sites with high security requirements should consider to chroot all daemons
392 that talk to the network: the smtp(8) and smtpd(8) processes, and perhaps also
393 the lmtp(8) client. The author's own porcupine.org mail server runs all daemons
394 chrooted that can be chrooted.
396 The default /etc/postfix/master.cf file specifies that no Postfix daemon runs
397 chrooted. In order to enable chroot operation, edit the file /etc/postfix/
398 master.cf, and follow instructions in the file. When you're finished, execute
399 "postfix reload" to make the change effective.
401 Note that a chrooted daemon resolves all filenames relative to the Postfix
402 queue directory (/var/spool/postfix). For successful use of a chroot jail, most
403 UNIX systems require you to bring in some files or device nodes. The examples/
404 chroot-setup directory in the source code distribution has a collection of
405 scripts that help you set up Postfix chroot environments on different operating
408 Additionally, you almost certainly need to configure syslogd so that it listens
409 on a socket inside the Postfix queue directory. Examples of syslogd command
410 line options that achieve this for specific systems:
412 FreeBSD: syslogd -l /var/spool/postfix/var/run/log
414 Linux, OpenBSD: syslogd -a /var/spool/postfix/dev/log
416 M
\bMy
\by o
\bow
\bwn
\bn h
\bho
\bos
\bst
\btn
\bna
\bam
\bme
\be
418 The myhostname parameter specifies the fully-qualified domain name of the
419 machine running the Postfix system. $myhostname appears as the default value in
420 many other Postfix configuration parameters.
422 By default, myhostname is set to the local machine name. If your local machine
423 name is not in fully-qualified domain name form, or if you run Postfix on a
424 virtual interface, you will have to specify the fully-qualified domain name
425 that the mail system should use.
427 Alternatively, if you specify mydomain in main.cf, then Postfix will use its
428 value to generate a fully-qualified default value for the myhostname parameter.
430 Examples (specify only one of the following):
432 /etc/postfix/main.cf:
433 myhostname = host.local.domain (machine name is not FQDN)
434 myhostname = host.virtual.domain (virtual interface)
435 myhostname = virtual.domain (virtual interface)
437 M
\bMy
\by o
\bow
\bwn
\bn d
\bdo
\bom
\bma
\bai
\bin
\bn n
\bna
\bam
\bme
\be
439 The mydomain parameter specifies the parent domain of $myhostname. By default,
440 it is derived from $myhostname by stripping off the first part (unless the
441 result would be a top-level domain).
443 Conversely, if you specify mydomain in main.cf, then Postfix will use its value
444 to generate a fully-qualified default value for the myhostname parameter.
446 Examples (specify only one of the following):
448 /etc/postfix/main.cf:
449 mydomain = local.domain
450 mydomain = virtual.domain (virtual interface)
452 M
\bMy
\by o
\bow
\bwn
\bn n
\bne
\bet
\btw
\bwo
\bor
\brk
\bk a
\bad
\bdd
\bdr
\bre
\bes
\bss
\bse
\bes
\bs
454 The inet_interfaces parameter specifies all network interface addresses that
455 the Postfix system should listen on; mail addressed to "user@[network address]"
456 will be delivered locally, as if it is addressed to a domain listed in
459 You can override the inet_interfaces setting in the Postfix master.cf file by
460 prepending an IP address to a server name.
462 The default is to listen on all active interfaces. If you run mailers on
463 virtual interfaces, you will have to specify what interfaces to listen on.
465 IMPORTANT: If you run MTAs on virtual interfaces you must specify explicit
466 inet_interfaces values for the MTA that receives mail for the machine itself:
467 this MTA should never listen on the virtual interfaces or you would have a
468 mailer loop when a virtual MTA is down.
470 Example: default setting.
472 /etc/postfix/main.cf:
473 inet_interfaces = all
475 Example: host running one or more virtual mailers. For each Postfix instance,
476 specify only one of the following.
478 /etc/postfix/main.cf:
479 inet_interfaces = virtual.host.tld (virtual Postfix)
480 inet_interfaces = $myhostname localhost... (non-virtual Postfix)
482 Note: you need to stop and start Postfix after changing this parameter.