1 P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx A
\bAr
\brc
\bch
\bhi
\bit
\bte
\bec
\bct
\btu
\bur
\bre
\be O
\bOv
\bve
\ber
\brv
\bvi
\bie
\bew
\bw
3 -------------------------------------------------------------------------------
5 I
\bIn
\bnt
\btr
\bro
\bod
\bdu
\buc
\bct
\bti
\bio
\bon
\bn
7 This document presents an overview of the Postfix architecture, and provides
8 pointers to descriptions of every Postfix command or server program. The text
9 gives the general context in which each command or server program is used, and
10 provides pointers to documents with specific usage examples and background
13 Topics covered by this document:
15 * How Postfix receives mail
16 * How Postfix delivers mail
17 * Postfix behind the scenes
18 * Postfix support commands
20 H
\bHo
\bow
\bw P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx r
\bre
\bec
\bce
\bei
\biv
\bve
\bes
\bs m
\bma
\bai
\bil
\bl
22 When a message enters the Postfix mail system, the first stop on the inside is
23 the incoming queue. The figure below shows the main processes that are involved
24 with new mail. Names followed by a number are Postfix commands or server
25 programs, while unnumbered names inside shaded areas represent Postfix queues.
35 Network -> qmqpd(8) -> cleanup(8) -> incoming
44 Local -> sendmail(1) -> postdrop(1)
46 * Network mail enters Postfix via the smtpd(8) or qmqpd(8) servers. These
47 servers remove the SMTP or QMQP protocol encapsulation, enforce some sanity
48 checks to protect Postfix, and give the sender, recipients and message
49 content to the cleanup(8) server. The smtpd(8) server can be configured to
50 block unwanted mail, as described in the SMTPD_ACCESS_README document.
52 * Local submissions are received with the Postfix sendmail(1) compatibility
53 command, and are queued in the maildrop queue by the privileged postdrop(1)
54 command. This arrangement even works while the Postfix mail system is not
55 running. The local pickup(8) server picks up local submissions, enforces
56 some sanity checks to protect Postfix, and gives the sender, recipients and
57 message content to the cleanup(8) server.
59 * Mail from internal sources is given directly to the cleanup(8) server.
60 These sources are not shown in the figure, and include: mail that is
61 forwarded by the local(8) delivery agent (see next section), messages that
62 are returned to the sender by the bounce(8) server (see second-next
63 section), and postmaster notifications about problems with Postfix.
65 * The cleanup(8) server implements the final processing stage before mail is
66 queued. It adds missing From: and other message headers, and transforms
67 addresses as described in the ADDRESS_REWRITING_README document.
68 Optionally, the cleanup(8) server can be configured to do light-weight
69 content inspection with regular expressions as described in the
70 BUILTIN_FILTER_README document. The cleanup(8) server places the result as
71 a single file into the incoming queue, and notifies the queue manager (see
72 next section) of the arrival of new mail.
74 * The trivial-rewrite(8) server rewrites addresses to the standard
75 "user@fully.qualified.domain" form, as described in the
76 ADDRESS_REWRITING_README document. Postfix currently does not implement a
77 rewriting language, but a lot can be done via table lookups and, if need
78 be, regular expressions.
80 H
\bHo
\bow
\bw P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx d
\bde
\bel
\bli
\biv
\bve
\ber
\brs
\bs m
\bma
\bai
\bil
\bl
82 Once a message has reached the incoming queue the next step is to deliver it.
83 The figure shows the main components of the Postfix mail delivery apparatus.
84 Names followed by a number are Postfix commands or server programs, while
85 unnumbered names inside shaded areas represent Postfix queues.
87 trivial- smtp(8) -> Network
95 incoming -> active -> qmgr(8) --- local(8) -> File, command
99 | v - virtual(8) -> File
105 * The queue manager (the qmgr(8) server process in the figure) is the heart
106 of Postfix mail delivery. It contacts the smtp(8), lmtp(8), local(8),
107 virtual(8), pipe(8), discard(8) or error(8) delivery agents, and sends a
108 delivery request for one or more recipient addresses. The discard(8) and
109 error(8) delivery agents are special: they discard or bounce all mail, and
110 are not shown in the figure above.
112 The queue manager maintains a small active queue with the messages that it
113 has opened for delivery. The active queue acts as a limited window on
114 potentially large incoming or deferred queues. The limited active queue
115 prevents the queue manager from running out of memory under heavy load.
117 The queue manager maintains a separate deferred queue for mail that cannot
118 be delivered, so that a large mail backlog will not slow down normal queue
119 accesses. The queue manager's strategy for delayed mail delivery attempts
120 is described in the QSHAPE_README and TUNING_README documents.
122 * The trivial-rewrite(8) server resolves each recipient address according to
123 its local or remote address class, as defined in the ADDRESS_CLASS_README
124 document. Additional routing information can be specified with the optional
125 transport(5) table. The trivial-rewrite(8) server optionally queries the
126 relocated(5) table for recipients whose address has changed; mail for such
127 recipients is returned to the sender with an explanation.
129 * The smtp(8) client looks up a list of mail exchangers for the destination
130 host, sorts the list by preference, and tries each server in turn until it
131 finds a server that responds. It then encapsulates the sender, recipient
132 and message content as required by the SMTP protocol; this includes
133 conversion of 8-bit MIME to 7-bit encoding.
135 * The lmtp(8) client speaks a protocol similar to SMTP that is optimized for
136 delivery to mailbox servers such as Cyrus. The advantage of this setup is
137 that one Postfix machine can feed multiple mailbox servers over LMTP. The
138 opposite is true as well: one mailbox server can be fed over LMTP by
139 multiple Postfix machines.
141 * The local(8) delivery agent understands UNIX-style mailboxes, qmail-
142 compatible maildir files, Sendmail-style system-wide aliases(5) databases,
143 and Sendmail-style per-user .forward files. Multiple local delivery agents
144 can be run in parallel, but parallel delivery to the same user is usually
147 The local(8) delivery agent has hooks for alternative forms of local
148 delivery: you can configure it to deliver to mailbox files in user home
149 directories, you can configure it to delegate mailbox delivery to an
150 external command such as procmail, or you can delegate delivery to a
151 different Postfix delivery agent.
153 * The virtual(8) delivery agent is a bare-bones delivery agent that delivers
154 to UNIX-style mailbox or qmail-style maildir files only. This delivery
155 agent can deliver mail for multiple domains, which makes it especially
156 suitable for hosting lots of small domains on a single machine. This is
157 described in the VIRTUAL_README document.
159 * The pipe(8) mailer is the outbound interface to other mail processing
160 systems (the Postfix sendmail(1) command being the inbound interface). The
161 interface is UNIX compatible: it provides information on the command line
162 and on the standard input stream, and expects a process exit status code as
163 defined in <sysexits.h>. Examples of delivery via the pipe(8) mailer are in
164 the MAILDROP_README and UUCP_README documents.
166 P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx b
\bbe
\beh
\bhi
\bin
\bnd
\bd t
\bth
\bhe
\be s
\bsc
\bce
\ben
\bne
\bes
\bs
168 The previous sections gave an overview of how Postfix server processes send and
169 receive mail. These server processes rely on other server processes that do
170 things behind the scenes. The text below attempts to visualize each service in
171 its own context. As before, names followed by a number are Postfix commands or
172 server programs, while unnumbered names inside shaded areas represent Postfix
175 * The resident master(8) server is the supervisor that keeps an eye on the
176 well-being of the Postfix mail system. It is typically started at system
177 boot time with the "postfix start" command, and keeps running until the
178 system goes down. The master(8) server is responsible for starting Postfix
179 server processes to receive and deliver mail, and for restarting servers
180 that terminate prematurely because of some problem. The master(8) server is
181 also responsible for enforcing the server process count limits as specified
182 in the m
\bma
\bas
\bst
\bte
\ber
\br.
\b.c
\bcf
\bf configuration file. The picture below gives the program
183 hierarchy when Postfix is started up. Only some of the mail handling daemon
197 postsuper(1) master(8) postlog(1)
203 smtpd(8) qmgr(8) local(8)
205 * The anvil(8) server implements client connection and request rate limiting
206 for all smtpd(8) servers. The TUNING_README document provides guidance for
207 dealing with mis-behaving SMTP clients. The anvil(8) service is available
208 in Postfix version 2.2 and later.
210 Network -> smtpd(8) <-> anvil(8)
212 * The bounce(8), defer(8) and trace(8) services each maintain their own queue
213 directory trees with per-message logfiles. Postfix uses this information
214 when sending "failed", "delayed" or "success" delivery status notifications
217 The trace(8) service also implements support for the Postfix "sendmail -bv"
218 and "sendmail -v" commands which produce reports about how Postfix delivers
219 mail, and is available with Postfix version 2.1 and later. See DEBUG_README
223 cleanup(8) -> Postfix -> agents
229 (Non-) bounce(8) Queue id,
230 delivery <- defer(8) <- recipient,
231 notice trace(8) status
240 * The flush(8) servers maintain per-destination logs and implement both ETRN
241 and "sendmail -qRdestination", as described in the ETRN_README document.
242 This moves selected queue files from the deferred queue back to the
243 incoming queue and requests their delivery. The flush(8) service is
244 available with Postfix version 1.0 and later.
253 smtpd(8) Destination Deferred Delivery
254 sendmail(1) - to flush -> flush(8) <- destination, - agents,
255 postqueue(1) queue id qmgr(8)
264 * The proxymap(8) servers provide read-only and read-write table lookup
265 service to Postfix processes. This overcomes chroot restrictions, reduces
266 the number of open lookup tables by sharing one open table among multiple
267 processes, and implements single-updater tables.
269 * The scache(8) server maintains the connection cache for the Postfix smtp(8)
270 client. When connection caching is enabled for selected destinations, the
271 smtp(8) client does not disconnect immediately after a mail transaction,
272 but gives the connection to the connection cache server which keeps the
273 connection open for a limited amount of time. The smtp(8) client continues
274 with some other mail delivery request. Meanwhile, any smtp(8) process can
275 ask the scache(8) server for that cached connection and reuse it for mail
276 delivery. As a safety measure, Postfix limits the number of times that a
277 connection may be reused.
279 When delivering mail to a destination with multiple mail servers,
280 connection caching can help to skip over a non-responding server, and thus
281 dramatically speed up delivery. SMTP connection caching is available in
282 Postfix version 2.2 and later. More information about this feature is in
283 the CONNECTION_CACHE_README document.
285 /-- smtp(8) --> Internet
289 \-- | smtp(8) --> Internet
296 * The showq(8) servers list the Postfix queue status. This is the queue
297 listing service that does the work for the mailq(1) and postqueue(1)
301 Output <- post- <- showq(8) <- queue
304 * The spawn(8) servers run non-Postfix commands on request, with the client
305 connected via socket or FIFO to the command's standard input, output and
306 error streams. You can find examples of its use in the SMTPD_POLICY_README
309 * The tlsmgr(8) server runs when TLS (Transport Layer Security, formerly
310 known as SSL) is turned on in the Postfix smtp(8) client or smtpd(8)
311 server. This process has two duties:
313 o Maintain the pseudo-random number generator (PRNG) that is used to seed
314 the TLS engines in Postfix smtp(8) client or smtpd(8) server processes.
315 The state of this PRNG is periodically saved to a file, and is read
316 when tlsmgr(8) starts up.
318 o Maintain the optional Postfix smtp(8) client or smtpd(8) server caches
319 with TLS session keys. Saved keys can improve performance by reducing
320 the amount of computation at the start of a TLS session.
322 TLS support is available in Postfix version 2.2 and later. Information
323 about the Postfix TLS implementation is in the TLS_README document.
325 <---seed--- ---seed--->
326 Network-> smtpd(8) tlsmgr(8) smtp(8) ->Network
327 <-session-> <-session->
334 session state session
337 * The verify(8) server verifies that a sender or recipient address is
338 deliverable before the smtpd(8) server accepts it. The verify(8) server
339 injects probe messages into the Postfix queue and processes status updates
340 from delivery agents and/or queue manager. This process is described in the
341 ADDRESS_VERIFICATION_README document. The verify(8) service is available
342 with Postfix version 2.1 and later.
345 Network -> smtpd(8) <-> verify(8) -> cleanup(8) -> Postfix -> agents
353 P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx s
\bsu
\bup
\bpp
\bpo
\bor
\brt
\bt c
\bco
\bom
\bmm
\bma
\ban
\bnd
\bds
\bs
355 The Postfix architecture overview ends with a summary of command-line utilities
356 for day-to-day use of the Postfix mail system. Besides the Sendmail-compatible
357 sendmail(1), mailq(1), and newaliases(1) commands, the Postfix system comes
358 with it own collection of command-line utilities. For consistency, these are
359 all named postsomething.
361 * The postfix(1) command controls the operation of the mail system. It is the
362 interface for starting, stopping, and restarting the mail system, as well
363 as for some other administrative operations. This command is reserved to
366 * The postalias(1) command maintains Postfix aliases(5) type databases. This
367 is the program that does the work for the newaliases(1) command.
369 * The postcat(1) command displays the contents of Postfix queue files. This
370 is a limited, preliminary utility. This program is likely to be superseded
371 by something more powerful that can also edit Postfix queue files.
373 * The postconf(1) command displays or updates Postfix main.cf parameters and
374 displays system dependent information about the supported file locking
375 methods, and the supported types of lookup tables.
377 * The postdrop(1) command is the mail posting utility that is run by the
378 Postfix sendmail(1) command in order to deposit mail into the maildrop
381 * The postkick(1) command makes some Postfix internal communication channels
382 available for use in, for example, shell scripts.
384 * The postlock(1) command provides Postfix-compatible mailbox locking for use
385 in, for example, shell scripts.
387 * The postlog(1) command provides Postfix-compatible logging for shell
390 * The postmap(1) command maintains Postfix lookup tables such as canonical
391 (5), virtual(5) and others. It is a cousin of the UNIX makemap command.
393 * The postmulti(1) command repeats the "postfix start" etc. command for each
394 Postfix instance, and supports creation, deletion etc. of Postfix
395 instances. For a tutorial, see MULTI_INSTANCE_README.
397 * The postqueue(1) command is the privileged command that is run by Postfix
398 sendmail(1) and mailq(1) in order to flush or list the mail queue.
400 * The postsuper(1) command maintains the Postfix queue. It removes old
401 temporary files, and moves queue files into the right directory after a
402 change in the hashing depth of queue directories. This command is run at
403 mail system startup time and when Postfix is restarted.