~ubuntu-branches/ubuntu/dapper/postfix/dapper-security

« back to all changes in this revision

Viewing changes to README_FILES/ADDRESS_REWRITING_README

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2005-02-27 09:33:07 UTC
  • Revision ID: james.westby@ubuntu.com-20050227093307-cn789t27ibnlh6tf
Tags: upstream-2.1.5
ImportĀ upstreamĀ versionĀ 2.1.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
PPoossttffiixx AAddddrreessss RReewwrriittiinngg
 
2
 
 
3
-------------------------------------------------------------------------------
 
4
 
 
5
PPoossttffiixx aaddddrreessss rreewwrriittiinngg ppuurrppoossee
 
6
 
 
7
Address rewriting is at the heart of the Postfix mail system. Postfix rewrites
 
8
addresses for many different purposes. Some are merely cosmetic, and some are
 
9
necessary to deliver correctly formatted mail to the correct destination.
 
10
Examples of address rewriting in Postfix are:
 
11
 
 
12
  * Transform an incomplete address into a complete address. For example,
 
13
    transform "username" into "username@example.com", or transform
 
14
    "username@hostname" into "username@hostname.example.com".
 
15
 
 
16
  * Replace an address by an equivalent address. For example, replace
 
17
    "username@example.com" by "firstname.lastname@example.com" when sending
 
18
    mail, and do the reverse transformation when receiving mail.
 
19
 
 
20
  * Replace an address by multiple addresses. For example, replace the address
 
21
    of an alias by the addresses listed under that alias.
 
22
 
 
23
  * Determine how and where to deliver mail for a specific address. For
 
24
    example, deliver mail for "username@example.com" with the smtp(8) delivery
 
25
    agent, to the hosts that are listed in the DNS as the mail servers for the
 
26
    domain "example.com".
 
27
 
 
28
Although Postfix currently has no address rewriting language, it can do
 
29
surprisingly powerful address manipulation via table lookup. Postfix typically
 
30
uses lookup tables with fixed strings to map one address to one or multiple
 
31
addresses, and typically uses regular expressions to map multiple addresses to
 
32
one or multiple addresses. Fixed-string lookup tables may be in the form of
 
33
local files, or in the form of NIS, LDAP or SQL databases. The DATABASE_README
 
34
document gives an introduction to Postfix lookup tables.
 
35
 
 
36
Topics covered in this document:
 
37
 
 
38
  * Postfix address rewriting overview
 
39
  * Address rewriting when mail is received
 
40
 
 
41
      o Rewrite addresses to standard form
 
42
      o Canonical address mapping
 
43
      o Address masquerading
 
44
      o Automatic BCC recipients
 
45
      o Virtual aliasing
 
46
 
 
47
  * Address rewriting when mail is delivered
 
48
 
 
49
      o Resolve address to destination
 
50
      o Mail transport switch
 
51
      o Relocated users table
 
52
      o Local alias database
 
53
      o Local per-user .forward files
 
54
      o Local catch-all address
 
55
 
 
56
  * Debugging your address manipulations
 
57
 
 
58
PPoossttffiixx aaddddrreessss rreewwrriittiinngg oovveerrvviieeww
 
59
 
 
60
The figure below zooms in on those parts of Postfix that are most involved with
 
61
address rewriting activity. See the OVERVIEW document for an overview of the
 
62
complete Postfix architecture. Names followed by a number are Postfix daemon
 
63
programs, while unnumbered names represent Postfix queues or internal sources
 
64
of mail messages.
 
65
 
 
66
                  trivial-                              trivial-
 
67
                 rewrite(8)                            rewrite(8)
 
68
                 (std form)                            (resolve)
 
69
 
 
70
                      ^ |                                   ^ |
 
71
                      | v                                   | v
 
72
 
 
73
    smtpd(8)                                                         smtp(8)
 
74
 
 
75
    qmqpd(8)  >- cleanup(8) -> incoming ->  active  ->   qmgr(8)  -< lmtp(8)
 
76
 
 
77
    pickup(8)                                                        local(8)
 
78
 
 
79
                       ^                      ^ |
 
80
                       |                      | v
 
81
 
 
82
                  bounces
 
83
                 forwarding                deferred
 
84
                  notices
 
85
 
 
86
The table below summarizes all Postfix address manipulations. If you're reading
 
87
this document for the first time, skip forward to "Address rewriting when mail
 
88
is received". Once you've finished reading the remainder of this document, the
 
89
table will help you to quickly find what you need.
 
90
 
 
91
     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 
92
    |AAddddrreessss     |SSccooppee|DDaaeemmoonn  |GGlloobbaall ttuurrnn--oonn      |SSeelleeccttiivvee ttuurrnn--ooffff      |
 
93
    |mmaanniippuullaattiioonn|     |        |ccoonnttrrooll             |ccoonnttrrooll                 |
 
94
    |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
 
95
    |Rewrite     |     |trivial-|append_at_myorigin, |                        |
 
96
    |addresses to|all  |rewrite |append_dot_mydomain,|none                    |
 
97
    |standard    |mail |(8)     |swap_bangpath,      |                        |
 
98
    |form        |     |        |allow_percent_hack  |                        |
 
99
    |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
 
100
    |Canonical   |all  |cleanup |                    |                        |
 
101
    |address     |mail |(8)     |canonical_maps      |receive_override_options|
 
102
    |mapping     |     |        |                    |                        |
 
103
    |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
 
104
    |Address     |all  |cleanup |masquerade_domains  |receive_override_options|
 
105
    |masquerading|mail |(8)     |                    |                        |
 
106
    |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
 
107
    |Automatic   |new  |cleanup |always_bcc,         |                        |
 
108
    |BCC         |mail |(8)     |sender_bcc_maps,    |receive_override_options|
 
109
    |recipients  |     |        |recipient_bcc_maps  |                        |
 
110
    |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
 
111
    |Virtual     |all  |cleanup |virtual_alias_maps  |receive_override_options|
 
112
    |aliasing    |mail |(8)     |                    |                        |
 
113
    |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
 
114
    |Resolve     |all  |trivial-|                    |                        |
 
115
    |address to  |mail |rewrite |none                |none                    |
 
116
    |destination |     |(8)     |                    |                        |
 
117
    |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
 
118
    |Mail        |all  |trivial-|                    |                        |
 
119
    |transport   |mail |rewrite |transport_maps      |none                    |
 
120
    |switch      |     |(8)     |                    |                        |
 
121
    |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
 
122
    |Relocated   |all  |trivial-|                    |                        |
 
123
    |users table |mail |rewrite |relocated_maps      |none                    |
 
124
    |            |     |(8)     |                    |                        |
 
125
    |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
 
126
    |Local alias |all  |local(8)|alias_maps          |none                    |
 
127
    |database    |mail |        |                    |                        |
 
128
    |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
 
129
    |Local per-  |     |        |                    |                        |
 
130
    |user        |all  |local(8)|forward_path        |none                    |
 
131
    |.forward    |mail |        |                    |                        |
 
132
    |files       |     |        |                    |                        |
 
133
    |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
 
134
    |Local catch-|all  |local(8)|luser_relay         |none                    |
 
135
    |all address |mail |        |                    |                        |
 
136
    |_ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _|_ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |
 
137
 
 
138
AAddddrreessss rreewwrriittiinngg wwhheenn mmaaiill iiss rreecceeiivveedd
 
139
 
 
140
The cleanup(8) server receives mail from outside of Postfix as well as mail
 
141
from internal sources such as forwarded mail, undeliverable mail that is
 
142
bounced to the sender, and postmaster notifications about problems with the
 
143
mail system.
 
144
 
 
145
The cleanup(8) server transforms the sender, recipients and message content
 
146
into a standard form before writing it to an incoming queue file. The server
 
147
cleans up sender and recipient addresses in message headers and in the
 
148
envelope, adds missing message headers such as From: or Date: that are required
 
149
by mail standards, and removes message headers such as Bcc: that should not be
 
150
present. The cleanup(8) server delegates the more complex address manipulations
 
151
to the trivial-rewrite(8) server as described later in this document.
 
152
 
 
153
Address manipulations at this stage are:
 
154
 
 
155
  * Rewrite addresses to standard form
 
156
  * Canonical address mapping
 
157
  * Address masquerading
 
158
  * Automatic BCC recipients
 
159
  * Virtual aliasing
 
160
 
 
161
RReewwrriittee aaddddrreesssseess ttoo ssttaannddaarrdd ffoorrmm
 
162
 
 
163
Before the cleanup(8) daemon runs an address through any address mapping lookup
 
164
table, it first rewrites the address to the standard
 
165
"user@fully.qualified.domain" form, by sending the address to the trivial-
 
166
rewrite(8) daemon. The purpose of rewriting to standard form is to reduce the
 
167
number of entries needed in lookup tables.
 
168
 
 
169
The Postfix trivial-rewrite(8) daemon implements the following hard-coded
 
170
address manipulations:
 
171
 
 
172
    Rewrite "@hosta,@hostb:user@site" to "user@site"
 
173
        In case you wonder what this is, the address form above is called a
 
174
        route address, and specifies that mail for "user@site" be delivered via
 
175
        "hosta" and "hostb". Usage of this form has been deprecated for a long
 
176
        time. Postfix has no ability to handle route addresses, other than to
 
177
        strip off the route part.
 
178
 
 
179
    Rewrite "site!user" to "user@site"
 
180
        This feature is controlled by the boolean swap_bangpath parameter
 
181
        (default: yes). The purpose is to rewrite UUCP-style addresses to
 
182
        domain style. This is useful only when you receive mail via UUCP, but
 
183
        it probably does not hurt otherwise.
 
184
 
 
185
    Rewrite "user%domain" to "user@domain"
 
186
        This feature is controlled by the boolean allow_percent_hack parameter
 
187
        (default: yes). Typically, this is used in order to deal with
 
188
        monstrosities such as "user%domain@otherdomain".
 
189
 
 
190
    Rewrite "user" to "user@$myorigin"
 
191
        This feature is controlled by the boolean append_at_myorigin parameter
 
192
        (default: yes). You should never turn off this feature, because a lot
 
193
        of Postfix components expect that all addresses have the form
 
194
        "user@domain".
 
195
 
 
196
        If your machine is not the main machine for $myorigin and you wish to
 
197
        have some users delivered locally without going via that main machine,
 
198
        make an entry in the virtual alias table that redirects
 
199
        "user@$myorigin" to "user@$myhostname". See also the "delivering some
 
200
        users locally" section in the STANDARD_CONFIGURATION_README document.
 
201
 
 
202
    Rewrite "user@host" to "user@host.$mydomain"
 
203
        This feature is controlled by the boolean append_dot_mydomain parameter
 
204
        (default: yes). The purpose is to get consistent treatment of different
 
205
        forms of the same hostname.
 
206
 
 
207
        Some will argue that rewriting "host" to "host.$mydomain" is bad. That
 
208
        is why it can be turned off. Others like the convenience of having the
 
209
        local domain appended automatically.
 
210
 
 
211
    Rewrite "user@site." to "user@site" (without the trailing dot).
 
212
        A single trailing dot is silently removed. However, an address that
 
213
        ends in multiple dots will be rejected as an invalid address.
 
214
 
 
215
CCaannoonniiccaall aaddddrreessss mmaappppiinngg
 
216
 
 
217
The cleanup(8) daemon uses the canonical(5) tables to rewrite all addresses in
 
218
message envelopes and in message headers. This is done for local and remote
 
219
addresses. The mapping is useful to replace login names by "Firstname.Lastname"
 
220
style addresses, or to clean up invalid domains in mail addresses produced by
 
221
legacy mail systems.
 
222
 
 
223
Canonical mapping is disabled by default. To enable, edit the canonical_maps
 
224
parameter in the main.cf file and specify one or more lookup tables, separated
 
225
by whitespace or commas.
 
226
 
 
227
Example:
 
228
 
 
229
    /etc/postfix/main.cf:
 
230
        canonical_maps = hash:/etc/postfix/canonical
 
231
 
 
232
    /etc/postfix/canonical:
 
233
        wietse        Wietse.Venema
 
234
 
 
235
For static mappings as shown above, lookup tables such as hash:, ldap:, mysql:
 
236
or pgsql: are sufficient. For dynamic mappings you can use regular expression
 
237
tables. This requires that you become intimately familiar with the ideas
 
238
expressed in regexp_table(5), pcre_table(5) and canonical(5).
 
239
 
 
240
In addition to the canonical maps which are applied to both sender and
 
241
recipient addresses, you can specify canonical maps that are applied only to
 
242
sender addresses or to recipient addresses.
 
243
 
 
244
Example:
 
245
 
 
246
    /etc/postfix/main.cf:
 
247
        sender_canonical_maps = hash:/etc/postfix/sender_canonical
 
248
        recipient_canonical_maps = hash:/etc/postfix/recipient_canonical
 
249
 
 
250
The sender and recipient canonical maps are applied before the common canonical
 
251
maps.
 
252
 
 
253
Sender-specific rewriting is useful when you want to rewrite ugly sender
 
254
addresses to pretty ones, and still want to be able to send mail to the those
 
255
ugly address without creating a mailer loop.
 
256
 
 
257
Canonical mapping can be turned off selectively for mail received by smtpd(8),
 
258
qmqpd(8), or pickup(8), by overriding main.cf settings in the master.cf file.
 
259
This feature is available in Postfix version 2.1 and later.
 
260
 
 
261
Example:
 
262
 
 
263
    /etc/postfix/master.cf:
 
264
        :10026      inet  n       -       n       -       -       smtpd
 
265
            -o receive_override_options=no_address_mapping
 
266
 
 
267
Note: do not specify whitespace around the "=" here.
 
268
 
 
269
AAddddrreessss mmaassqquueerraaddiinngg
 
270
 
 
271
Address masquerading is a method to hide hosts inside a domain behind their
 
272
mail gateway, and to make it appear as if the mail comes from the gateway
 
273
itself, instead of from individual machines.
 
274
 
 
275
Address masquerading is disabled by default, and is implemented by the cleanup
 
276
(8) server. To enable, edit the masquerade_domains parameter in the main.cf
 
277
file and specify one or more domain names separated by whitespace or commas.
 
278
When Postfix tries to masquerade a domain, it processes the list from left to
 
279
right, and processing stops at the first match.
 
280
 
 
281
Example:
 
282
 
 
283
    /etc/postfix/main.cf:
 
284
        masquerade_domains = foo.example.com example.com
 
285
 
 
286
strips "any.thing.foo.example.com" to "foo.example.com", but strips
 
287
"any.thing.else.example.com" to "example.com".
 
288
 
 
289
A domain name prefixed with "!" means do not masquerade this domain or its
 
290
subdomains:
 
291
 
 
292
    /etc/postfix/main.cf:
 
293
        masquerade_domains = !foo.example.com example.com
 
294
 
 
295
does not change "any.thing.foo.example.com" and "foo.example.com", but strips
 
296
"any.thing.else.example.com" to "example.com".
 
297
 
 
298
The masquerade_exceptions configuration parameter specifies what user names
 
299
should not be subjected to address masquerading. Specify one or more user names
 
300
separated by whitespace or commas.
 
301
 
 
302
Example:
 
303
 
 
304
    /etc/postfix/main.cf:
 
305
        masquerade_exceptions = root
 
306
 
 
307
By default, Postfix makes no exceptions.
 
308
 
 
309
Subtle point: by default, address masquerading is applied only to message
 
310
headers and to envelope sender addresses, but not to envelope recipients. This
 
311
allows you to use address masquerading on a mail gateway machine, while still
 
312
being able to forward mail from outside to users on individual machines.
 
313
 
 
314
In order to subject envelope recipient addresses to masquerading, too, specify
 
315
(Postfix version 1.1 and later):
 
316
 
 
317
    /etc/postfix/main.cf:
 
318
        masquerade_classes = envelope_sender, envelope_recipient,
 
319
            header_sender, header_recipient
 
320
 
 
321
If you rewrite the envelope recipient like this, Postfix will no longer be able
 
322
to send mail to individual machines.
 
323
 
 
324
Address masquerading can be turned off selectively for mail received by smtpd
 
325
(8), qmqpd(8), or pickup(8), by overriding main.cf settings in the master.cf
 
326
file. This feature is available in Postfix version 2.1 and later.
 
327
 
 
328
Example:
 
329
 
 
330
    /etc/postfix/master.cf:
 
331
        :10026      inet  n       -       n       -       -       smtpd
 
332
            -o receive_override_options=no_address_mapping
 
333
 
 
334
Note: do not specify whitespace around the "=" here.
 
335
 
 
336
AAuuttoommaattiicc BBCCCC rreecciippiieennttss
 
337
 
 
338
After applying the canonical and masquerade mappings, the cleanup(8) daemon can
 
339
generate optional BCC (blind carbon-copy) recipients. Postfix provides three
 
340
mechanisms:
 
341
 
 
342
    always_bcc = address
 
343
        Deliver a copy of all mail to the specified address. In Postfix
 
344
        versions before 2.1, this feature is implemented by smtpd(8), qmqpd(8),
 
345
        or pickup(8).
 
346
    sender_bcc_maps = type:table
 
347
        Search the specified "type:table" lookup table with the envelope sender
 
348
        address for an automatic BCC address. This feature is available in
 
349
        Postfix 2.1 and later.
 
350
    recipient_bcc_maps = type:table
 
351
        Search the specified "type:table" lookup table with the envelope
 
352
        recipient address for an automatic BCC address. This feature is
 
353
        available in Postfix 2.1 and later.
 
354
 
 
355
Note: automatic BCC recipients are produced only for new mail. To avoid mailer
 
356
loops, automatic BCC recipients are not generated for mail that Postfix
 
357
forwards internally, nor for mail that Postfix generates itself.
 
358
 
 
359
Automatic BCC recipients (including always_bcc) can be turned off selectively
 
360
for mail received by smtpd(8), qmqpd(8), or pickup(8), by overriding main.cf
 
361
settings in the master.cf file. This feature is available in Postfix version
 
362
2.1 and later.
 
363
 
 
364
Example:
 
365
 
 
366
    /etc/postfix/master.cf:
 
367
        :10026      inet  n       -       n       -       -       smtpd
 
368
            -o receive_override_options=no_address_mapping
 
369
 
 
370
Note: do not specify whitespace around the "=" here.
 
371
 
 
372
VViirrttuuaall aalliiaassiinngg
 
373
 
 
374
Before writing the recipients to the queue file, the cleanup(8) daemon uses the
 
375
optional virtual(5) alias tables to redirect mail for recipients. The mapping
 
376
affects only envelope recipient addresses; it has no effect on message headers
 
377
or envelope sender addresses. Virtual alias lookups are useful to redirect mail
 
378
for virtual alias domains to real user mailboxes, and to redirect mail for
 
379
domains that no longer exist. Virtual alias lookups can also be used to
 
380
transform " Firstname.Lastname " back into UNIX login names, although it seems
 
381
that local aliases may be a more appropriate vehicle. See the VIRTUAL_README
 
382
document for an overview of methods to host virtual domains with Postfix.
 
383
 
 
384
Virtual aliasing is disabled by default. To enable, edit the virtual_alias_maps
 
385
parameter in the main.cf file and specify one or more lookup tables, separated
 
386
by whitespace or commas.
 
387
 
 
388
Example:
 
389
 
 
390
    /etc/postfix/main.cf:
 
391
        virtual_alias_maps = hash:/etc/postfix/virtual
 
392
 
 
393
    /etc/postfix/virtual:
 
394
        Wietse.Venema        wietse
 
395
 
 
396
Addresses found in virtual alias maps are subjected to another iteration of
 
397
virtual aliasing, but are not subjected to canonical mapping, in order to avoid
 
398
loops.
 
399
 
 
400
For static mappings as shown above, lookup tables such as hash:, ldap:, mysql:
 
401
or pgsql: are sufficient. For dynamic mappings you can use regular expression
 
402
tables. This requires that you become intimately familiar with the ideas
 
403
expressed in regexp_table(5), pcre_table(5) and virtual(5).
 
404
 
 
405
Note: automatic BCC recipients are produced only for new mail. To avoid mailer
 
406
loops, automatic BCC recipients are not generated for mail that is forwarded
 
407
internally, and are not generated for mail that is generated by Postfix itself.
 
408
 
 
409
Virtual aliasing can be turned off selectively for mail received by smtpd(8),
 
410
qmqpd(8), or pickup(8), by overriding main.cf settings in the master.cf file.
 
411
This feature is available in Postfix version 2.1 and later.
 
412
 
 
413
Example:
 
414
 
 
415
    /etc/postfix/master.cf:
 
416
        :10026      inet  n       -       n       -       -       smtpd
 
417
            -o receive_override_options=no_address_mapping
 
418
 
 
419
Note: do not specify whitespace around the "=" here.
 
420
 
 
421
At this point the message is ready to be stored into the Postfix incoming
 
422
queue.
 
423
 
 
424
AAddddrreessss rreewwrriittiinngg wwhheenn mmaaiill iiss ddeelliivveerreedd
 
425
 
 
426
The Postfix queue manager sorts mail according to its destination and gives it
 
427
to Postfix delivery agents such as local(8), smtp(8), or lmtp(8). Just like the
 
428
cleanup(8) server, the Postfix queue manager delegates the more complex address
 
429
manipulations to the trivial-rewrite(8) server.
 
430
 
 
431
Address manipulations at this stage are:
 
432
 
 
433
  * Resolve address to destination
 
434
  * Mail transport switch
 
435
  * Relocated users table
 
436
 
 
437
Each Postfix delivery agent tries to deliver the mail to its destination, while
 
438
encapsulating the sender, recipients, and message content according to the
 
439
rules of the SMTP, LMTP, etc. protocol. When mail cannot be delivered, it is
 
440
either returned to the sender or moved to the deferred queue and tried again
 
441
later.
 
442
 
 
443
Address manipulations when mail is delivered via the local(8) delivery agent:
 
444
 
 
445
  * Local alias database
 
446
  * Local per-user .forward files
 
447
  * Local catch-all address
 
448
 
 
449
The remainder of this document presents each address manipulation step in more
 
450
detail, with specific examples or with pointers to documentation with examples.
 
451
 
 
452
RReessoollvvee aaddddrreessss ttoo ddeessttiinnaattiioonn
 
453
 
 
454
The Postfix qmgr(8) queue manager selects new mail from the incoming queue or
 
455
old mail from the deferred queue, and asks the trivial-rewrite(8) address
 
456
rewriting and resolving daemon where it should be delivered.
 
457
 
 
458
As of version 2.0, Postfix distinguishes four major address classes. Each class
 
459
has its own list of domain names, and each class has its own default delivery
 
460
method, as shown in the table below. See the ADDRESS_CLASS_README document for
 
461
the fine details. Postfix versions before 2.0 only distinguish between local
 
462
delivery and everything else.
 
463
 
 
464
     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 
465
    |DDeessttiinnaattiioonn ddoommaaiinn lliisstt          |DDeeffaauulltt ddeelliivveerryy mmeetthhoodd|AAvvaaiillaabbiilliittyy|
 
466
    |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ |
 
467
    |$mydestination, $inet_interfaces,|$local_transport       |Postfix 1.0 |
 
468
    |$proxy_interfaces                |                       |            |
 
469
    |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ |
 
470
    |$virtual_mailbox_domains         |$virtual_transport     |Postfix 2.0 |
 
471
    |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ |
 
472
    |$relay_domains                   |$relay_transport       |Postfix 2.0 |
 
473
    |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ |
 
474
    |none                             |$default_transport     |Postfix 1.0 |
 
475
    |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ |
 
476
 
 
477
MMaaiill ttrraannssppoorrtt sswwiittcchh
 
478
 
 
479
Once the trivial-rewrite(8) daemon has determined a default delivery method it
 
480
searches the optional transport(5) table for information that overrides the
 
481
message destination and/or delivery method. Typical use of the transport(5) is
 
482
to send mail to a system that is not connected to the Internet, or to use a
 
483
special SMTP client configuration for destinations that have special
 
484
requirements. See, for example, the STANDARD_CONFIGURATION_README and
 
485
UUCP_README documents, and the examples in the transport(5) manual page.
 
486
 
 
487
Transport table lookups are disabled by default. To enable, edit the
 
488
transport_maps parameter in the main.cf file and specify one or more lookup
 
489
tables, separated by whitespace or commas.
 
490
 
 
491
Example:
 
492
 
 
493
    /etc/postfix/main.cf:
 
494
        transport_maps = hash:/etc/postfix/transport
 
495
 
 
496
RReellooccaatteedd uusseerrss ttaabbllee
 
497
 
 
498
Next, the trivial-rewrite(8) address rewriting and resolving daemon runs each
 
499
recipient through the relocated(5) database. This table provides information on
 
500
how to reach users that no longer have an account, or what to do with mail for
 
501
entire domains that no longer exist. When mail is sent to an address that is
 
502
listed in this table, the message is returned to the sender with an informative
 
503
message.
 
504
 
 
505
The relocated(5) database is searched after transport(5) table lookups, in
 
506
anticipation of transport(5) tables that can replace one recipient address by a
 
507
different one.
 
508
 
 
509
Lookups of relocated users are disabled by default. To enable, edit the
 
510
relocated_maps parameter in the main.cf file and specify one or more lookup
 
511
tables, separated by whitespace or commas.
 
512
 
 
513
Example:
 
514
 
 
515
    /etc/postfix/main.cf:
 
516
        relocated_maps = hash:/etc/postfix/relocated
 
517
 
 
518
    /etc/postfix/relocated:
 
519
        username@example.com      otheruser@elsewhere.tld
 
520
 
 
521
As of Postfix version 2, mail for a relocated user will be rejected by the SMTP
 
522
server with the reason "user has moved to otheruser@elsewhere.tld". Older
 
523
Postfix versions will receive the mail first, and then return it to the sender
 
524
as undeliverable, with the same reason.
 
525
 
 
526
LLooccaall aalliiaass ddaattaabbaassee
 
527
 
 
528
When mail is to be delivered locally, the local(8) delivery agent runs each
 
529
local recipient name through the aliases(5) database. The mapping does not
 
530
affect addresses in message headers. Local aliases are typically used to
 
531
implement distribution lists, or to direct mail for standard aliases such as
 
532
postmaster to real people. The table can also be used to map
 
533
"Firstname.Lastname" addresses to login names.
 
534
 
 
535
Alias lookups are enabled by default. The default configuration depends on the
 
536
operating system environment, but it is typically one of the following:
 
537
 
 
538
    /etc/postfix/main.cf:
 
539
        alias_maps = hash:/etc/aliases
 
540
        alias_maps = dbm:/etc/aliases, nis:mail.aliases
 
541
 
 
542
The pathname of the alias database file is controlled with the alias_database
 
543
configuration parameter. The value is system dependent. Usually it is one of
 
544
the following:
 
545
 
 
546
    /etc/postfix/main.cf:
 
547
        alias_database = hash:/etc/aliases (4.4BSD, LINUX)
 
548
        alias_database = dbm:/etc/aliases (4.3BSD, SYSV<4)
 
549
        alias_database = dbm:/etc/mail/aliases (SYSV4)
 
550
 
 
551
An aliases(5) file can specify that mail should be delivered to a local file,
 
552
or to a command that receives the message in the standard input stream. For
 
553
security reasons, deliveries to command and file destinations are performed
 
554
with the rights of the alias database owner. A default userid, default_privs,
 
555
is used for deliveries to commands or files in "root"-owned aliases.
 
556
 
 
557
LLooccaall ppeerr--uusseerr ..ffoorrwwaarrdd ffiilleess
 
558
 
 
559
With delivery via the local(8) deliver agent, users can control their own mail
 
560
delivery by specifying destinations in a file called .forward in their home
 
561
directories. The syntax of these files is the same as with the local aliases(5)
 
562
file, except that the left-hand side of the alias (lookup key and colon) are
 
563
not present.
 
564
 
 
565
LLooccaall ccaattcchh--aallll aaddddrreessss
 
566
 
 
567
When the local(8) delivery agent finds that a message recipient does not exist,
 
568
the message is normally returned to the sender ("user unknown"). Sometimes it
 
569
is desirable to forward mail for non-existing recipients to another machine.
 
570
For this purpose you can specify an alternative destination with the
 
571
luser_relay configuration parameter.
 
572
 
 
573
Alternatively, mail for non-existent recipients can be delegated to an entirely
 
574
different message transport, as specified with the fallback_transport
 
575
configuration parameter. For details, see the local(8) delivery agent
 
576
documentation.
 
577
 
 
578
Note: if you use the luser_relay feature in order to receive mail for non-UNIX
 
579
accounts, then you must specify:
 
580
 
 
581
    /etc/postfix/main.cf:
 
582
        local_recipient_maps =
 
583
 
 
584
(i.e. empty) in the main.cf file, otherwise the Postfix SMTP server will reject
 
585
mail for non-UNIX accounts with "User unknown in local recipient table". See
 
586
the LOCAL_RECIPIENT_README file for more information on this.
 
587
 
 
588
luser_relay can specify one address. It is subjected to "$name" expansions.
 
589
Examples:
 
590
 
 
591
    $user@other.host
 
592
        The bare username, without address extension, is prepended to
 
593
        "@other.host". For example, mail for "username+foo" is sent to
 
594
        "username@other.host".
 
595
 
 
596
    $local@other.host
 
597
        The entire original recipient localpart, including address extension,
 
598
        is prepended to "@other.host". For example, mail for "username+foo" is
 
599
        sent to "username+foo@other.host".
 
600
 
 
601
    sysadmin+$user
 
602
        The bare username, without address extension, is appended to
 
603
        "sysadmin". For example, mail for "username+foo" is sent to
 
604
        "sysadmin+username".
 
605
 
 
606
    sysadmin+$local
 
607
        The entire original recipient localpart, including address extension,
 
608
        is appended to "sysadmin". For example, mail for "username+foo" is sent
 
609
        to "sysadmin+username+foo".
 
610
 
 
611
DDeebbuuggggiinngg yyoouurr aaddddrreessss mmaanniippuullaattiioonnss
 
612
 
 
613
With Postfix version 2.1 and later you can ask Postfix to produce mail delivery
 
614
reports for debugging purposes. These reports not only show sender/recipient
 
615
addresses after address rewriting and alias expansion or forwarding, they also
 
616
show information about delivery to mailbox, delivery to non-Postfix command,
 
617
responses from remote SMTP servers, and so on.
 
618
 
 
619
Postfix can produce two types of mail delivery reports for debugging:
 
620
 
 
621
  * What-if: report what would happen, but do not actually deliver mail. This
 
622
    mode of operation is requested with:
 
623
 
 
624
    $ //uussrr//ssbbiinn//sseennddmmaaiill --bbvv aaddddrreessss......
 
625
    Mail Delivery Status Report will be mailed to <your login name>.
 
626
 
 
627
  * What happened: deliver mail and report successes and/or failures, including
 
628
    replies from remote SMTP servers. This mode of operation is requested with:
 
629
 
 
630
    $ //uussrr//ssbbiinn//sseennddmmaaiill --vv aaddddrreessss......
 
631
    Mail Delivery Status Report will be mailed to <your login name>.
 
632
 
 
633
These reports contain information that is generated by Postfix delivery agents.
 
634
Since these run as daemon processes and do not interact with users directly,
 
635
the result is sent as mail to the sender of the test message. The format of
 
636
these reports is practically identical to that of ordinary non-delivery
 
637
notifications.
 
638
 
 
639
As an example, below is the delivery report that is produced with the command
 
640
"sendmail -bv postfix-users@postfix.org". The first part of the report contains
 
641
human-readable text. In this case, mail would be delivered via mail.cloud9.net,
 
642
and the SMTP server replies with "250 Ok". Other reports may show delivery to
 
643
mailbox, or delivery to non-Postfix command.
 
644
 
 
645
    Content-Description: Notification
 
646
    Content-Type: text/plain
 
647
 
 
648
    This is the Postfix program at host spike.porcupine.org.
 
649
 
 
650
    Enclosed is the mail delivery report that you requested.
 
651
 
 
652
                            The Postfix program
 
653
 
 
654
    <postfix-users@postfix.org>: delivery via mail.cloud9.net[168.100.1.4]: 250
 
655
    Ok
 
656
 
 
657
The second part of the report is in machine-readable form, and includes the
 
658
following information:
 
659
 
 
660
  * The envelope sender address (wietse@porcupine.org).
 
661
  * The envelope recipient address (postfix-users@postfix.org). If the
 
662
    recipient address was changed by Postfix then Postfix also includes the
 
663
    original recipient address.
 
664
  * The delivery status.
 
665
 
 
666
Some details are still preliminary and will change as Postfix implements the
 
667
DSN (delivery status notification) standards.
 
668
 
 
669
    Content-Description: Delivery report
 
670
    Content-Type: message/delivery-status
 
671
 
 
672
    Reporting-MTA: dns; spike.porcupine.org
 
673
    X-Postfix-Queue-ID: 84863BC0E5
 
674
    X-Postfix-Sender: rfc822; wietse@porcupine.org
 
675
    Arrival-Date: Tue, 13 Apr 2004 19:27:43 -0400 (EDT)
 
676
 
 
677
    Final-Recipient: rfc822; postfix-users@postfix.org
 
678
    Action: deliverable
 
679
    Status: 2.0.0
 
680
    Diagnostic-Code: X-Postfix; delivery via mail.cloud9.net[168.100.1.4]: 250
 
681
    Ok
 
682
 
 
683
The third part of the report contains the message that Postfix would have
 
684
delivered, including From: and To: message headers, so that you can see any
 
685
effects of address rewriting on those. Mail submitted with "sendmail -bv" has
 
686
no body content so none is shown in the example below.
 
687
 
 
688
    Content-Description: Message
 
689
    Content-Type: message/rfc822
 
690
 
 
691
    Received: by spike.porcupine.org (Postfix, from userid 1001)
 
692
            id 84863BC0E5; Tue, 13 Apr 2004 19:27:43 -0400 (EDT)
 
693
    Subject: probe
 
694
    To: postfix-users@postfix.org
 
695
    Message-Id: <20040413232743.84863BC0E5@spike.porcupine.org>
 
696
    Date: Tue, 13 Apr 2004 19:27:43 -0400 (EDT)
 
697
    From: wietse@porcupine.org (Wietse Venema)
 
698