1 <!doctype html public
"-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
8 <title>Postfix Address Rewriting
</title>
10 <meta http-equiv=
"Content-Type" content=
"text/html; charset=us-ascii">
16 <h1><img src=
"postfix-logo.jpg" width=
"203" height=
"98" ALT=
"">Postfix
17 Address Rewriting
</h1>
21 <h2> <a name=
"purpose"> Postfix address rewriting purpose
</a> </h2>
23 <p> Address rewriting is at the heart of the Postfix mail system.
24 Postfix rewrites addresses for many different purposes. Some are
25 merely cosmetic, and some are necessary to deliver correctly
26 formatted mail to the correct destination. Examples of
27 address rewriting in Postfix are:
</p>
31 <li> <p> Transform an incomplete address into a complete address.
32 For example, transform
"username" into
"username@example.com", or
33 transform
"username@hostname" into
"username@hostname.example.com".
36 <li> <p> Replace an address by an equivalent address. For example,
37 replace
"username@example.com" by
"firstname.lastname@example.com"
38 when sending mail, and do the reverse transformation when receiving
41 <li> <p> Replace an internal address by an external address. For
42 example, replace
"username@localdomain.local" by
"isp-account@isp.example"
43 when sending mail from a home computer to the Internet.
46 <li> <p> Replace an address by multiple addresses. For example,
47 replace the address of an alias by the addresses listed under that
50 <li> <p> Determine how and where to deliver mail for a specific
51 address. For example, deliver mail for
"username@example.com" with
52 the
<a href=
"smtp.8.html">smtp(
8)
</a> delivery agent, to the hosts that are listed in the
53 DNS as the mail servers for the domain
"example.com".
</p>
57 <p> Although Postfix currently has no address rewriting language,
58 it can do surprisingly powerful address manipulation via table
59 lookup. Postfix typically uses lookup tables with fixed strings
60 to map one address to one or multiple addresses, and typically uses
61 regular expressions to map multiple addresses to one or multiple
62 addresses. Fixed-string lookup tables may be in the form of local
63 files, or in the form of NIS, LDAP or SQL databases. The
64 <a href=
"DATABASE_README.html">DATABASE_README
</a> document gives an introduction to Postfix lookup
67 <p> Topics covered in this document:
</p>
71 <li> <a href=
"#william"> To rewrite message headers or not, or to label
74 <li> <a href=
"#overview"> Postfix address rewriting overview
</a>
76 <li> <a href=
"#receiving"> Address rewriting when mail is received
</a>
80 <li> <a href=
"#standard"> Rewrite addresses to standard form
</a>
82 <li> <a href=
"#canonical"> Canonical address mapping
</a>
84 <li> <a href=
"#masquerade"> Address masquerading
</a>
86 <li> <a href=
"#auto_bcc"> Automatic BCC recipients
</a>
88 <li> <a href=
"#virtual"> Virtual aliasing
</a>
92 <li> <a href=
"#delivering"> Address rewriting when mail is delivered
</a>
96 <li> <a href=
"#resolve"> Resolve address to destination
</a>
98 <li> <a href=
"#transport"> Mail transport switch
</a>
100 <li> <a href=
"#relocated"> Relocated users table
</a>
104 <li> <a href=
"#remote"> Address rewriting with remote delivery
</a>
108 <li> <a href=
"#generic"> Generic mapping for outgoing SMTP mail
</a>
112 <li> <a href=
"#local"> Address rewriting with local delivery
</a>
116 <li> <a href=
"#aliases"> Local alias database
</a>
118 <li> <a href=
"#forward"> Local per-user .forward files
</a>
120 <li> <a href=
"#luser_relay"> Local catch-all address
</a>
124 <li> <a href=
"#debugging"> Debugging your address manipulations
</a>
128 <h2> <a name=
"william"> To rewrite message headers or not, or to label
129 as invalid
</a> </h2>
131 <p> Postfix versions
2.1 and earlier always rewrite message header
132 addresses, and append Postfix's own domain information to addresses
133 that Postfix considers incomplete. While rewriting message header
134 addresses is OK for mail with a local origin, it is undesirable
135 for remote mail:
</p>
139 <li> Message header address rewriting is frowned upon by mail standards,
141 <li> Appending Postfix's own domain produces incorrect results with
142 some incomplete addresses,
144 <li> Appending Postfix's own domain sometimes creates the appearance
145 that spam is sent by local users.
149 <p> Postfix versions
2.2 give you the option to either not rewrite
150 message headers from remote SMTP clients at all, or to label
151 incomplete addresses in such message headers as invalid. Here is
156 <li> Postfix always rewrites message headers from local SMTP clients
157 and from the Postfix sendmail command, and appends its own domain
158 to incomplete addresses. The
<a href=
"postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients
</a> parameter
159 controls what SMTP clients Postfix considers local (by default,
160 only local network interface addresses).
162 <li> Postfix never rewrites message header addresses from remote
163 SMTP clients when the
<a href=
"postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain
</a> parameter value
164 is empty (the default setting).
166 <li> Otherwise, Postfix rewrites message headers from remote SMTP
167 clients, and appends the
<a href=
"postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain
</a> value to
168 incomplete addresses. This feature can be used to append a reserved
169 domain such as
"domain.invalid", so that incomplete addresses cannot
170 be mistaken for local addresses.
174 <h2> <a name=
"overview"> Postfix address rewriting overview
</a> </h2>
176 <p> The figure below zooms in on those parts of Postfix that are most
177 involved with address rewriting activity. See the
<a href=
"OVERVIEW.html">OVERVIEW
</a> document
178 for an overview of the complete Postfix architecture. Names followed
179 by a number are Postfix daemon programs, while unnumbered names
180 represent Postfix queues or internal sources of mail messages.
</p>
188 <td colspan=
"2"> </td>
190 <td bgcolor=
"#f0f0ff" align=
"center"> <a href=
"trivial-rewrite.8.html">trivial-
<br>rewrite(
8)
</a><br>(std
193 <td colspan=
"5"> </td>
195 <td bgcolor=
"#f0f0ff" align=
"center"> <a href=
"trivial-rewrite.8.html">trivial-
<br>rewrite(
8)
</a><br>(resolve)
202 <td colspan=
"2"> </td>
204 <td align=
"center"><table><tr><td align=
"center"> ^
<br> <tt> |
205 </tt> </td><td align=
"center"> <tt> |
<br>v
</tt> </td></tr></table>
207 <td colspan=
"5"> </td>
209 <td align=
"center"><table><tr><td align=
"center"> ^
<br> <tt> |
210 </tt> </td><td align=
"center"> <tt> |
<br>v
</tt> </td></tr></table>
212 <td colspan=
"2"> </td>
218 <td bgcolor=
"#f0f0ff" align=
"center" valign=
"middle"> <a href=
"smtpd.8.html">smtpd(
8)
</a>
221 <td rowspan=
"3" align=
"center" valign=
"middle"> <tt> >-
</tt>
224 <td rowspan=
"3" bgcolor=
"#f0f0ff" align=
"center"> <a href=
"cleanup.8.html">cleanup(
8)
</a> </td>
226 <td rowspan=
"3" align=
"center" valign=
"middle"> <tt> -
> </tt>
229 <td rowspan=
"3" bgcolor=
"#f0f0ff" align=
"center"> <a
230 href=
"QSHAPE_README.html#incoming_queue"> incoming
</a> </td>
232 <td rowspan=
"3" align=
"center" valign=
"middle"> <tt> -
> </tt>
235 <td rowspan=
"3" bgcolor=
"#f0f0ff" align=
"center"> <a
236 href=
"QSHAPE_README.html#active_queue"> active
</a> </td>
238 <td rowspan=
"3" align=
"center" valign=
"middle"> <tt> -
> </tt>
241 <td rowspan=
"3" bgcolor=
"#f0f0ff" align=
"center"> <a href=
"qmgr.8.html">qmgr(
8)
</a> </td>
243 <td rowspan=
"3" align=
"center" valign=
"middle"> <tt> -
< </tt>
246 <td bgcolor=
"#f0f0ff" align=
"center" valign=
"middle">
247 <a href=
"smtp.8.html">smtp(
8)
</a> </td>
253 <td bgcolor=
"#f0f0ff" align=
"center" valign=
"middle">
254 <a href=
"qmqpd.8.html">qmqpd(
8)
</a> </td>
256 <td bgcolor=
"#f0f0ff" align=
"center" valign=
"middle"> <a href=
"lmtp.8.html">lmtp(
8)
</a> </td>
262 <td bgcolor=
"#f0f0ff" align=
"center" valign=
"middle"> <a href=
"pickup.8.html">pickup(
8)
</a>
265 <td bgcolor=
"#f0f0ff" align=
"center" valign=
"middle"> <a href=
"local.8.html">local(
8)
</a>
272 <td colspan=
"2"> </td>
274 <td align=
"center"> ^
<br> <tt> |
</tt> </td>
276 <td colspan=
"3"> </td>
278 <td align=
"center"><table><tr><td align=
"center"> ^
<br> <tt> |
279 </tt> </td><td align=
"center"> <tt> |
<br>v
</tt> </td></tr></table>
281 <td colspan=
"4"> </td>
287 <td colspan=
"2"> </td>
289 <td align=
"center"> bounces
<br> forwarding
<br> notices
</td>
291 <td colspan=
"3"> </td>
293 <td bgcolor=
"#f0f0ff" align=
"center"> <a
294 href=
"QSHAPE_README.html#deferred_queue"> deferred
</a>
296 <td colspan=
"2"> </td>
302 <p> The table below summarizes all Postfix address manipulations.
303 If you're reading this document for the first time, skip forward
304 to
"<a href="ADDRESS_REWRITING_README.html#receiving
">Address
305 rewriting when mail is received</a>". Once you've finished reading
306 the remainder of this document, the table will help you to quickly
307 find what you need.
</p>
313 <tr> <th nowrap
> Address manipulation
</th> <th nowrap
> Scope
</th>
314 <th> Daemon
</th> <th nowrap
> Global turn-on control
</th> <th nowrap
> Selective
315 turn-off control
</th> </tr>
317 <tr> <td> <a href=
"#standard"> Rewrite addresses to standard form
</a>
318 </td> <td nowrap
> all mail
</td> <td> <a href=
"trivial-rewrite.8.html">trivial-
<br>rewrite(
8)
</a> </td>
319 <td> <a href=
"postconf.5.html#append_at_myorigin">append_at_myorigin
</a>,
<a href=
"postconf.5.html#append_dot_mydomain">append_dot_mydomain
</a>,
<a href=
"postconf.5.html#swap_bangpath">swap_bangpath
</a>,
320 <a href=
"postconf.5.html#allow_percent_hack">allow_percent_hack
</a> </td> <td> <a href=
"postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients
</a>,
321 <a href=
"postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain
</a> </td> </tr>
323 <tr> <td> <a href=
"#canonical"> Canonical address mapping
</a> </td>
324 <td nowrap
> all mail
</td> <td> <a href=
"cleanup.8.html">cleanup(
8)
</a> </td> <td> <a href=
"postconf.5.html#canonical_maps">canonical_maps
</a>
325 </td> <td> <a href=
"postconf.5.html#receive_override_options">receive_override_options
</a>,
<a href=
"postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients
</a>,
326 <a href=
"postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain
</a> </td> </tr>
328 <tr> <td> <a href=
"#masquerade"> Address masquerading
</a> </td> <td
329 nowrap
> all mail
</td> <td> <a href=
"cleanup.8.html">cleanup(
8)
</a> </td> <td> <a href=
"postconf.5.html#masquerade_domains">masquerade_domains
</a>
330 </td> <td> <a href=
"postconf.5.html#receive_override_options">receive_override_options
</a>,
<a href=
"postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients
</a>,
331 <a href=
"postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain
</a> </td> </tr>
333 <tr> <td> <a href=
"#auto_bcc"> Automatic BCC recipients
</a> </td>
334 <td nowrap
> new mail
</td> <td> <a href=
"cleanup.8.html">cleanup(
8)
</a> </td> <td> <a href=
"postconf.5.html#always_bcc">always_bcc
</a>,
335 <a href=
"postconf.5.html#sender_bcc_maps">sender_bcc_maps
</a>,
<a href=
"postconf.5.html#recipient_bcc_maps">recipient_bcc_maps
</a> </td> <td> <a href=
"postconf.5.html#receive_override_options">receive_override_options
</a>
338 <tr> <td> <a href=
"#virtual"> Virtual aliasing
</a> </td> <td
339 nowrap
> all mail
</td> <td> <a href=
"cleanup.8.html">cleanup(
8)
</a> </td> <td> <a href=
"postconf.5.html#virtual_alias_maps">virtual_alias_maps
</a>
340 </td> <td> <a href=
"postconf.5.html#receive_override_options">receive_override_options
</a> </td> </tr>
342 <tr> <td> <a href=
"#resolve"> Resolve address to destination
</a>
343 </td> <td nowrap
> all mail
</td> <td> <a href=
"trivial-rewrite.8.html">trivial-
<br>rewrite(
8)
</a> </td>
344 <td> none
</td> <td> none
</td> </tr>
346 <tr> <td> <a href=
"#transport"> Mail transport switch
</a> </td>
347 <td nowrap
> all mail
</td> <td> <a href=
"trivial-rewrite.8.html">trivial-
<br>rewrite(
8)
</a> </td> <td>
348 <a href=
"postconf.5.html#transport_maps">transport_maps
</a> </td> <td> none
</td> </tr>
350 <tr> <td> <a href=
"#relocated"> Relocated users table
</a> </td>
351 <td nowrap
> all mail
</td> <td> <a href=
"trivial-rewrite.8.html">trivial-
<br>rewrite(
8)
</a> </td> <td>
352 <a href=
"postconf.5.html#relocated_maps">relocated_maps
</a> </td> <td> none
</td> </tr>
354 <tr> <td> <a href=
"#generic"> Generic mapping table
</a> </td> <td>
355 outgoing SMTP mail
</td> <td> <a href=
"smtp.8.html">smtp(
8)
</a> </td> <td> <a href=
"postconf.5.html#smtp_generic_maps">smtp_generic_maps
</a>
356 </td> <td> none
</td> </tr>
358 <tr> <td> <a href=
"#aliases"> Local alias database
</a> </td> <td>
359 local mail only
</td> <td> <a href=
"local.8.html">local(
8)
</a> </td> <td> <a href=
"postconf.5.html#alias_maps">alias_maps
</a> </td> <td> none
362 <tr> <td> <a href=
"#forward"> Local per-user .forward files
</a>
363 </td> <td> local mail only
</td> <td> <a href=
"local.8.html">local(
8)
</a> </td> <td> <a href=
"postconf.5.html#forward_path">forward_path
</a>
364 </td> <td> none
</td> </tr>
366 <tr> <td> <a href=
"#luser_relay"> Local catch-all address
</a> </td>
367 <td> local mail only
</td> <td> <a href=
"local.8.html">local(
8)
</a> </td> <td> <a href=
"postconf.5.html#luser_relay">luser_relay
</a> </td> <td>
374 <h2> <a name=
"receiving"> Address rewriting when mail is received
</a>
377 <p> The
<a href=
"cleanup.8.html">cleanup(
8)
</a> server receives mail from outside of Postfix as
378 well as mail from internal sources such as forwarded mail,
379 undeliverable mail that is bounced to the sender, and postmaster
380 notifications about problems with the mail system.
</p>
382 <p> The
<a href=
"cleanup.8.html">cleanup(
8)
</a> server transforms the sender, recipients and
383 message content into a standard form before writing it to an incoming
384 queue file. The server cleans up sender and recipient addresses in
385 message headers and in the envelope, adds missing message headers
386 such as From: or Date: that are required by mail standards, and
387 removes message headers such as Bcc: that should not be present.
388 The
<a href=
"cleanup.8.html">cleanup(
8)
</a> server delegates the more complex address manipulations
389 to the
<a href=
"trivial-rewrite.8.html">trivial-rewrite(
8)
</a> server as described later in this document.
392 <p> Address manipulations at this stage are:
</p>
396 <li> <a href=
"#standard"> Rewrite addresses to standard form
</a>
398 <li> <a href=
"#canonical"> Canonical address mapping
</a>
400 <li> <a href=
"#masquerade"> Address masquerading
</a>
402 <li> <a href=
"#auto_bcc"> Automatic BCC recipients
</a>
404 <li> <a href=
"#virtual"> Virtual aliasing
</a>
408 <h3> <a name=
"standard"> Rewrite addresses to standard form
</a> </h3>
410 <p> Before the
<a href=
"cleanup.8.html">cleanup(
8)
</a> daemon runs an address through any address
411 mapping lookup table, it first rewrites the address to the standard
412 "user@fully.qualified.domain" form, by sending the address to the
413 <a href=
"trivial-rewrite.8.html">trivial-rewrite(
8)
</a> daemon. The purpose of rewriting to standard
414 form is to reduce the number of entries needed in lookup tables.
417 <p> The Postfix
<a href=
"trivial-rewrite.8.html">trivial-rewrite(
8)
</a> daemon implements the following
418 hard-coded address manipulations:
</p>
424 <dt>Rewrite
"@hosta,@hostb:user@site" to
"user@site"</dt>
426 <dd> <p> In case you wonder what this is, the address form above
427 is called a route address, and specifies that mail for
"user@site"
428 be delivered via
"hosta" and
"hostb". Usage of this form has been
429 deprecated for a long time. Postfix has no ability to handle route
430 addresses, other than to strip off the route part.
</p>
432 <p> NOTE: Postfix versions
2.2 and later rewrite message headers
433 from remote SMTP clients only if the client matches the
434 <a href=
"postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients
</a> parameter, or if the
435 <a href=
"postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain
</a> configuration parameter specifies a
436 non-empty value. To get the behavior before Postfix
2.2, specify
437 "<a href="postconf
.5.html#local_header_rewrite_clients
">local_header_rewrite_clients</a> = static:all".
</p> </dd>
439 <dt>Rewrite
"site!user" to
"user@site" </dt>
441 <dd> <p> This feature is controlled by the boolean
<a href=
"postconf.5.html#swap_bangpath">swap_bangpath
</a>
442 parameter (default: yes). The purpose is to rewrite UUCP-style
443 addresses to domain style. This is useful only when you receive
444 mail via UUCP, but it probably does not hurt otherwise.
</p>
446 <p> NOTE: Postfix versions
2.2 and later rewrite message headers
447 from remote SMTP clients only if the client matches the
448 <a href=
"postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients
</a> parameter, or if the
449 <a href=
"postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain
</a> configuration parameter specifies a
450 non-empty value. To get the behavior before Postfix
2.2, specify
451 "<a href="postconf
.5.html#local_header_rewrite_clients
">local_header_rewrite_clients</a> = static:all".
</p> </dd>
453 <dt>Rewrite
"user%domain" to
"user@domain"</dt>
455 <dd> <p> This feature is controlled by the boolean
<a href=
"postconf.5.html#allow_percent_hack">allow_percent_hack
</a>
456 parameter (default: yes). Typically, this is used in order to deal
457 with monstrosities such as
"user%domain@otherdomain".
</p>
459 <p> NOTE: Postfix versions
2.2 and later rewrite message headers
460 from remote SMTP clients only if the client matches the
461 <a href=
"postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients
</a> parameter, or if the
462 <a href=
"postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain
</a> configuration parameter specifies a
463 non-empty value. To get the behavior before Postfix
2.2, specify
464 "<a href="postconf
.5.html#local_header_rewrite_clients
">local_header_rewrite_clients</a> = static:all".
</p> </dd>
468 Rewrite
"user" to
"user@$<a href="postconf
.5.html#myorigin
">myorigin</a>" </dt>
470 <dd> <p> This feature is controlled by the boolean
<a href=
"postconf.5.html#append_at_myorigin">append_at_myorigin
</a>
471 parameter (default: yes). You should never turn off this feature,
472 because a lot of Postfix components expect that all addresses have
473 the form
"user@domain".
</p>
475 <p> NOTE: Postfix versions
2.2 and later rewrite message headers
476 from remote SMTP clients only if the client matches the
477 <a href=
"postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients
</a> parameter; otherwise they append the
478 domain name specified with the
<a href=
"postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain
</a>
479 configuration parameter, if one is specified. To get the behavior
480 before Postfix
2.2, specify
"<a href="postconf
.5.html#local_header_rewrite_clients
">local_header_rewrite_clients</a> =
483 <p> If your machine is not the main machine for $
<a href=
"postconf.5.html#myorigin">myorigin
</a> and you
484 wish to have some users delivered locally without going via that
485 main machine, make an entry in the
<a href=
"#virtual">virtual
486 alias
</a> table that redirects
"user@$myorigin" to
487 "user@$<a href="postconf
.5.html#myhostname
">myhostname</a>". See also the
"delivering some
488 users locally" section in the
<a href=
"STANDARD_CONFIGURATION_README.html">STANDARD_CONFIGURATION_README
</a>
493 Rewrite
"user@host" to
"user@host.$<a href="postconf
.5.html#mydomain
">mydomain</a>" </dt>
495 <dd> <p> This feature is controlled by the boolean
<a href=
"postconf.5.html#append_dot_mydomain">append_dot_mydomain
</a>
496 parameter (default: yes). The purpose is to get consistent treatment
497 of different forms of the same hostname.
</p>
499 <p> NOTE: Postfix versions
2.2 and later rewrite message headers
500 from remote SMTP clients only if the client matches the
501 <a href=
"postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients
</a> parameter; otherwise they append the
502 domain name specified with the
<a href=
"postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain
</a>
503 configuration parameter, if one is specified. To get the behavior
504 before Postfix
2.2, specify
"<a href="postconf
.5.html#local_header_rewrite_clients
">local_header_rewrite_clients</a> =
507 <p> Some will argue that rewriting
"host" to
"host.domain"
508 is bad. That is why it can be turned off. Others like the convenience
509 of having Postfix's own domain appended automatically.
</p> </dd>
511 <dt>Rewrite
"user@site." to
"user@site" (without the trailing dot).
</dt>
513 <dd> <p> A single trailing dot is silently removed. However, an
514 address that ends in multiple dots will be rejected as an invalid
517 <p> NOTE: Postfix versions
2.2 and later rewrite message headers
518 from remote SMTP clients only if the client matches the
519 <a href=
"postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients
</a> parameter, or if the
520 <a href=
"postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain
</a> configuration parameter specifies a
521 non-empty value. To get the behavior before Postfix
2.2, specify
522 "<a href="postconf
.5.html#local_header_rewrite_clients
">local_header_rewrite_clients</a> = static:all".
</p> </dd>
528 <h3> <a name=
"canonical"> Canonical address mapping
</a> </h3>
530 <p> The
<a href=
"cleanup.8.html">cleanup(
8)
</a> daemon uses the
<a href=
"canonical.5.html">canonical(
5)
</a> tables to rewrite
531 addresses in message envelopes and in message headers. By default
532 all header and envelope addresses are rewritten; this is controlled
533 with the
<a href=
"postconf.5.html#canonical_classes">canonical_classes
</a> configuration parameter.
</p>
535 <p> NOTE: Postfix versions
2.2 and later rewrite message headers
536 from remote SMTP clients only if the client matches the
537 <a href=
"postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients
</a> parameter, or if the
538 <a href=
"postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain
</a> configuration parameter specifies a
539 non-empty value. To get the behavior before Postfix
2.2, specify
540 "<a href="postconf
.5.html#local_header_rewrite_clients
">local_header_rewrite_clients</a> = static:all".
</p>
542 <p> Address rewriting is
543 done for local and remote addresses. The mapping is useful to
544 replace login names by
"Firstname.Lastname" style addresses, or to
545 clean up invalid domains in mail addresses produced by legacy mail
548 <p> Canonical mapping is disabled by default. To enable, edit the
549 <a href=
"postconf.5.html#canonical_maps">canonical_maps
</a> parameter in the
<a href=
"postconf.5.html">main.cf
</a> file and specify one or
550 more lookup tables, separated by whitespace or commas.
</p>
556 /etc/postfix/
<a href=
"postconf.5.html">main.cf
</a>:
557 <a href=
"postconf.5.html#canonical_maps">canonical_maps
</a> = hash:/etc/postfix/canonical
559 /etc/postfix/canonical:
564 <p> For static mappings as shown above, lookup tables such as hash:,
565 <a href=
"ldap_table.5.html">ldap
</a>:,
<a href=
"mysql_table.5.html">mysql
</a>: or
<a href=
"pgsql_table.5.html">pgsql
</a>: are sufficient. For dynamic mappings you
566 can use regular expression tables. This requires that you become
567 intimately familiar with the ideas expressed in
<a href=
"regexp_table.5.html">regexp_table(
5)
</a>,
568 <a href=
"pcre_table.5.html">pcre_table(
5)
</a> and
<a href=
"canonical.5.html">canonical(
5)
</a>.
</p>
570 <p> In addition to the canonical maps which are applied to both sender
571 and recipient addresses, you can specify canonical maps that are
572 applied only to sender addresses or to recipient addresses.
</p>
578 /etc/postfix/
<a href=
"postconf.5.html">main.cf
</a>:
579 <a href=
"postconf.5.html#sender_canonical_maps">sender_canonical_maps
</a> = hash:/etc/postfix/sender_canonical
580 <a href=
"postconf.5.html#recipient_canonical_maps">recipient_canonical_maps
</a> = hash:/etc/postfix/recipient_canonical
584 <p> The sender and recipient canonical maps are applied before the
585 common canonical maps. The
<a href=
"postconf.5.html#sender_canonical_classes">sender_canonical_classes
</a> and
586 <a href=
"postconf.5.html#recipient_canonical_classes">recipient_canonical_classes
</a> parameters control what addresses are
587 subject to
<a href=
"postconf.5.html#sender_canonical_maps">sender_canonical_maps
</a> and
<a href=
"postconf.5.html#recipient_canonical_maps">recipient_canonical_maps
</a>
588 mappings, respectively.
</p>
590 <p> Sender-specific rewriting is useful when you want to rewrite
591 ugly sender addresses to pretty ones, and still want to be able to
592 send mail to the those ugly address without creating a mailer loop.
595 <p> Canonical mapping can be turned off selectively for mail received
596 by
<a href=
"smtpd.8.html">smtpd(
8)
</a>,
<a href=
"qmqpd.8.html">qmqpd(
8)
</a>, or
<a href=
"pickup.8.html">pickup(
8)
</a>, by overriding
<a href=
"postconf.5.html">main.cf
</a> settings
597 in the
<a href=
"master.5.html">master.cf
</a> file. This feature is available in Postfix version
604 /etc/postfix/
<a href=
"master.5.html">master.cf
</a>:
605 127.0.0.1:
10026 inet n - n - - smtpd
606 -o
<a href=
"postconf.5.html#receive_override_options">receive_override_options
</a>=
<a href=
"postconf.5.html#no_address_mappings">no_address_mappings
</a>
610 <p> Note: do not specify whitespace around the
"=" here.
</p>
612 <h3> <a name=
"masquerade"> Address masquerading
</a> </h3>
614 <p> Address masquerading is a method to hide hosts inside a domain
615 behind their mail gateway, and to make it appear as if the mail
616 comes from the gateway itself, instead of from individual machines.
619 <p> NOTE: Postfix versions
2.2 and later rewrite message headers
620 from remote SMTP clients only if the client matches the
621 <a href=
"postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients
</a> parameter, or if the
622 <a href=
"postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain
</a> configuration parameter specifies a
623 non-empty value. To get the behavior before Postfix
2.2, specify
624 "<a href="postconf
.5.html#local_header_rewrite_clients
">local_header_rewrite_clients</a> = static:all".
</p>
626 <p> Address masquerading is disabled by default, and is implemented
627 by the
<a href=
"cleanup.8.html">cleanup(
8)
</a> server. To enable, edit the
<a href=
"postconf.5.html#masquerade_domains">masquerade_domains
</a>
628 parameter in the
<a href=
"postconf.5.html">main.cf
</a> file and specify one or more domain names
629 separated by whitespace or commas. When Postfix tries to masquerade
630 a domain, it processes the list from left to right, and processing
631 stops at the first match.
</p>
637 /etc/postfix/
<a href=
"postconf.5.html">main.cf
</a>:
638 <a href=
"postconf.5.html#masquerade_domains">masquerade_domains
</a> = foo.example.com example.com
642 <p> strips
"any.thing.foo.example.com" to
"foo.example.com", but
643 strips
"any.thing.else.example.com" to
"example.com".
</p>
645 <p> A domain name prefixed with
"<tt>!</tt>" means do not masquerade
646 this domain or its subdomains:
</p>
650 /etc/postfix/
<a href=
"postconf.5.html">main.cf
</a>:
651 <a href=
"postconf.5.html#masquerade_domains">masquerade_domains
</a> = !foo.example.com example.com
655 <p> does not change
"any.thing.foo.example.com" and
"foo.example.com",
656 but strips
"any.thing.else.example.com" to
"example.com".
</p>
658 <p> The
<a href=
"postconf.5.html#masquerade_exceptions">masquerade_exceptions
</a> configuration parameter specifies
659 what user names should not be subjected to address masquerading.
660 Specify one or more user names separated by whitespace or commas.
667 /etc/postfix/
<a href=
"postconf.5.html">main.cf
</a>:
668 <a href=
"postconf.5.html#masquerade_exceptions">masquerade_exceptions
</a> = root
672 <p> By default, Postfix makes no exceptions.
</p>
674 <p> Subtle point: by default, address masquerading is applied only to
675 message headers and to envelope sender addresses, but not to envelope
676 recipients. This allows you to use address masquerading on a mail
677 gateway machine, while still being able to forward mail from outside
678 to users on individual machines.
</p>
680 <p> In order to subject envelope recipient addresses to masquerading,
681 too, specify (Postfix version
1.1 and later):
</p>
685 /etc/postfix/
<a href=
"postconf.5.html">main.cf
</a>:
686 <a href=
"postconf.5.html#masquerade_classes">masquerade_classes
</a> = envelope_sender, envelope_recipient,
687 header_sender, header_recipient
691 <p> If you rewrite the envelope recipient like this, Postfix will
692 no longer be able to send mail to individual machines.
</p>
694 <p> Address masquerading can be turned off selectively for mail
695 received by
<a href=
"smtpd.8.html">smtpd(
8)
</a>,
<a href=
"qmqpd.8.html">qmqpd(
8)
</a>, or
<a href=
"pickup.8.html">pickup(
8)
</a>, by overriding
<a href=
"postconf.5.html">main.cf
</a>
696 settings in the
<a href=
"master.5.html">master.cf
</a> file. This feature is available in
697 Postfix version
2.1 and later.
</p>
703 /etc/postfix/
<a href=
"master.5.html">master.cf
</a>:
704 127.0.0.1:
10026 inet n - n - - smtpd
705 -o
<a href=
"postconf.5.html#receive_override_options">receive_override_options
</a>=
<a href=
"postconf.5.html#no_address_mappings">no_address_mappings
</a>
709 <p> Note: do not specify whitespace around the
"=" here.
</p>
711 <h3> <a name=
"auto_bcc"> Automatic BCC recipients
</a> </h3>
713 <p> After applying the canonical and masquerade mappings, the
714 <a href=
"cleanup.8.html">cleanup(
8)
</a> daemon can generate optional BCC (blind carbon-copy)
715 recipients. Postfix provides three mechanisms:
</p>
721 <dt> <a href=
"postconf.5.html#always_bcc">always_bcc
</a> = address
</dt> <dd> Deliver a copy of all mail to
722 the specified address. In Postfix versions before
2.1, this feature
723 is implemented by
<a href=
"smtpd.8.html">smtpd(
8)
</a>,
<a href=
"qmqpd.8.html">qmqpd(
8)
</a>, or
<a href=
"pickup.8.html">pickup(
8)
</a>.
</dd>
725 <dt> <a href=
"postconf.5.html#sender_bcc_maps">sender_bcc_maps
</a> =
<a href=
"DATABASE_README.html">type:table
</a> </dt> <dd> Search the specified
726 "<a href="DATABASE_README.html
">type:table</a>" lookup table with the envelope sender address for an
727 automatic BCC address. This feature is available in Postfix
2.1
730 <dt> <a href=
"postconf.5.html#recipient_bcc_maps">recipient_bcc_maps
</a> =
<a href=
"DATABASE_README.html">type:table
</a> </dt> <dd> Search the specified
731 "<a href="DATABASE_README.html
">type:table</a>" lookup table with the envelope recipient address for
732 an automatic BCC address. This feature is available in Postfix
2.1
739 <p> Note: automatic BCC recipients are produced only for new mail.
740 To avoid mailer loops, automatic BCC recipients are not generated
741 for mail that Postfix forwards internally, nor for mail that Postfix
742 generates itself.
</p>
744 <p> Automatic BCC recipients (including
<a href=
"postconf.5.html#always_bcc">always_bcc
</a>) can be turned
745 off selectively for mail received by
<a href=
"smtpd.8.html">smtpd(
8)
</a>,
<a href=
"qmqpd.8.html">qmqpd(
8)
</a>, or
<a href=
"pickup.8.html">pickup(
8)
</a>,
746 by overriding
<a href=
"postconf.5.html">main.cf
</a> settings in the
<a href=
"master.5.html">master.cf
</a> file. This feature
747 is available in Postfix version
2.1 and later.
</p>
753 /etc/postfix/
<a href=
"master.5.html">master.cf
</a>:
754 127.0.0.1:
10026 inet n - n - - smtpd
755 -o
<a href=
"postconf.5.html#receive_override_options">receive_override_options
</a>=
<a href=
"postconf.5.html#no_address_mappings">no_address_mappings
</a>
759 <p> Note: do not specify whitespace around the
"=" here.
</p>
761 <h3> <a name=
"virtual"> Virtual aliasing
</a> </h3>
763 <p> Before writing the recipients to the queue file, the
<a href=
"cleanup.8.html">cleanup(
8)
</a>
764 daemon uses the optional
<a href=
"virtual.5.html">virtual(
5)
</a> alias tables to redirect mail
765 for recipients. The mapping affects only envelope recipient
766 addresses; it has no effect on message headers or envelope sender
767 addresses. Virtual alias lookups are useful to redirect mail for
768 <a href=
"ADDRESS_CLASS_README.html#virtual_alias_class">virtual alias domains
</a> to real user mailboxes, and to redirect mail
769 for domains that no longer exist. Virtual alias lookups can also
770 be used to transform
" Firstname.Lastname " back into UNIX login
771 names, although it seems that local
<a href=
"#aliases">aliases
</a>
772 may be a more appropriate vehicle. See the
<a href=
"VIRTUAL_README.html">VIRTUAL_README
</a> document
773 for an overview of methods to host virtual domains with Postfix.
776 <p> Virtual aliasing is disabled by default. To enable, edit the
777 <a href=
"postconf.5.html#virtual_alias_maps">virtual_alias_maps
</a> parameter in the
<a href=
"postconf.5.html">main.cf
</a> file and
778 specify one or more lookup tables, separated by whitespace or
785 /etc/postfix/
<a href=
"postconf.5.html">main.cf
</a>:
786 <a href=
"postconf.5.html#virtual_alias_maps">virtual_alias_maps
</a> = hash:/etc/postfix/virtual
788 /etc/postfix/virtual:
793 <p> Addresses found in virtual alias maps are subjected to another
794 iteration of virtual aliasing, but are not subjected to canonical
795 mapping, in order to avoid loops.
</p>
797 <p> For static mappings as shown above, lookup tables such as hash:,
798 <a href=
"ldap_table.5.html">ldap
</a>:,
<a href=
"mysql_table.5.html">mysql
</a>: or
<a href=
"pgsql_table.5.html">pgsql
</a>: are sufficient. For dynamic mappings you
799 can use regular expression tables. This requires that you become
800 intimately familiar with the ideas expressed in
<a href=
"regexp_table.5.html">regexp_table(
5)
</a>,
801 <a href=
"pcre_table.5.html">pcre_table(
5)
</a> and
<a href=
"virtual.5.html">virtual(
5)
</a>.
</p>
803 <p> Virtual aliasing can be turned off selectively for mail received
804 by
<a href=
"smtpd.8.html">smtpd(
8)
</a>,
<a href=
"qmqpd.8.html">qmqpd(
8)
</a>, or
<a href=
"pickup.8.html">pickup(
8)
</a>, by overriding
<a href=
"postconf.5.html">main.cf
</a> settings
805 in the
<a href=
"master.5.html">master.cf
</a> file. This feature is available in Postfix version
812 /etc/postfix/
<a href=
"master.5.html">master.cf
</a>:
813 127.0.0.1:
10026 inet n - n - - smtpd
814 -o
<a href=
"postconf.5.html#receive_override_options">receive_override_options
</a>=
<a href=
"postconf.5.html#no_address_mappings">no_address_mappings
</a>
818 <p> Note: do not specify whitespace around the
"=" here.
</p>
820 <p> At this point the message is ready to be stored into the
821 Postfix
<a href=
"QSHAPE_README.html#incoming_queue">incoming queue
</a>.
</p>
823 <h2> <a name=
"delivering"> Address rewriting when mail is delivered
</a> </h2>
825 <p> The Postfix queue manager sorts mail according to its destination
826 and gives it to Postfix delivery agents such as
<a href=
"local.8.html">local(
8)
</a>,
<a href=
"smtp.8.html">smtp(
8)
</a>,
827 or
<a href=
"lmtp.8.html">lmtp(
8)
</a>. Just like the
<a href=
"cleanup.8.html">cleanup(
8)
</a> server, the Postfix queue
828 manager delegates the more complex address manipulations to the
829 <a href=
"trivial-rewrite.8.html">trivial-rewrite(
8)
</a> server.
</p>
831 <p> Address manipulations at this stage are:
</p>
835 <li> <a href=
"#resolve"> Resolve address to destination
</a>
837 <li> <a href=
"#transport"> Mail transport switch
</a>
839 <li> <a href=
"#relocated"> Relocated users table
</a>
843 <p> Each Postfix delivery agent tries to deliver the mail to its
844 destination, while encapsulating the sender, recipients, and message
845 content according to the rules of the SMTP, LMTP, etc. protocol.
846 When mail cannot be delivered, it is either returned to the sender
847 or moved to the
<a href=
"QSHAPE_README.html#deferred_queue">deferred queue
</a> and tried again later.
</p>
849 <p> <a name=
"remote">Address
</a> manipulations when mail is delivered
850 via the
<a href=
"smtp.8.html">smtp(
8)
</a> delivery agent:
</p>
854 <li> <a href=
"#generic"> Generic mapping for outgoing SMTP mail
</a>
858 <p> <a name=
"local">Address
</a> manipulations when mail is delivered
859 via the
<a href=
"local.8.html">local(
8)
</a> delivery agent:
</p>
863 <li> <a href=
"#aliases"> Local alias database
</a>
865 <li> <a href=
"#forward"> Local per-user .forward files
</a>
867 <li> <a href=
"#luser_relay"> Local catch-all address
</a>
871 <p> The remainder of this document presents each address manipulation
872 step in more detail, with specific examples or with pointers to
873 documentation with examples.
</p>
875 <h3> <a name=
"resolve"> Resolve address to destination
</a> </h3>
877 <p> The Postfix
<a href=
"qmgr.8.html">qmgr(
8)
</a> queue manager selects new mail from the
878 <a href=
"QSHAPE_README.html#incoming_queue">incoming queue
</a> or old mail from the
<a href=
"QSHAPE_README.html#deferred_queue">deferred queue
</a>, and asks the
879 <a href=
"trivial-rewrite.8.html">trivial-rewrite(
8)
</a> address rewriting and resolving daemon where it
880 should be delivered.
</p>
882 <p> As of version
2.0, Postfix distinguishes four major address
883 classes. Each class has its own list of domain names, and each
884 class has its own default delivery method, as shown in the table
885 below. See the
<a href=
"ADDRESS_CLASS_README.html">ADDRESS_CLASS_README
</a> document for the fine details.
886 Postfix versions before
2.0 only distinguish between local delivery
887 and everything else.
</p>
893 <tr><th align=
"left">Destination domain list
</th> <th
894 align=
"left">Default delivery method
</th> <th>Availability
897 <tr><td>$
<a href=
"postconf.5.html#mydestination">mydestination
</a>, $
<a href=
"postconf.5.html#inet_interfaces">inet_interfaces
</a>, $
<a href=
"postconf.5.html#proxy_interfaces">proxy_interfaces
</a> </td>
898 <td>$
<a href=
"postconf.5.html#local_transport">local_transport
</a> </td> <td>Postfix
1.0</td></tr>
900 <tr><td>$
<a href=
"postconf.5.html#virtual_mailbox_domains">virtual_mailbox_domains
</a> </td> <td>$
<a href=
"postconf.5.html#virtual_transport">virtual_transport
</a> </td>
901 <td>Postfix
2.0</td> </tr>
903 <tr><td>$
<a href=
"postconf.5.html#relay_domains">relay_domains
</a> </td> <td>$
<a href=
"postconf.5.html#relay_transport">relay_transport
</a> </td> <td>Postfix
906 <tr><td>none
</td> <td>$
<a href=
"postconf.5.html#default_transport">default_transport
</a> </td> <td>Postfix
1.0</td>
913 <h3> <a name=
"transport"> Mail transport switch
</a> </h3>
915 <p> Once the
<a href=
"trivial-rewrite.8.html">trivial-rewrite(
8)
</a> daemon has determined a default
916 delivery method it searches the optional
<a href=
"transport.5.html">transport(
5)
</a> table for
917 information that overrides the message destination and/or delivery
918 method. Typical use of the
<a href=
"transport.5.html">transport(
5)
</a> table is to send mail to
920 that is not connected to the Internet, or to use a special SMTP
921 client configuration for destinations that have special requirements.
922 See, for example, the
<a href=
"STANDARD_CONFIGURATION_README.html">STANDARD_CONFIGURATION_README
</a> and
<a href=
"UUCP_README.html">UUCP_README
</a>
923 documents, and the examples in the
<a href=
"transport.5.html">transport(
5)
</a> manual page.
</p>
925 <p> Transport table lookups are disabled by default. To enable,
926 edit the
<a href=
"postconf.5.html#transport_maps">transport_maps
</a> parameter in the
<a href=
"postconf.5.html">main.cf
</a> file and specify
927 one or more lookup tables, separated by whitespace or commas.
</p>
933 /etc/postfix/
<a href=
"postconf.5.html">main.cf
</a>:
934 <a href=
"postconf.5.html#transport_maps">transport_maps
</a> = hash:/etc/postfix/transport
938 <h3> <a name=
"relocated"> Relocated users table
</a> </h3>
940 <p> Next, the
<a href=
"trivial-rewrite.8.html">trivial-rewrite(
8)
</a> address rewriting and resolving
941 daemon runs each recipient through the
<a href=
"relocated.5.html">relocated(
5)
</a> database. This
942 table provides information on how to reach users that no longer
943 have an account, or what to do with mail for entire domains that
944 no longer exist. When mail is sent to an address that is listed
945 in this table, the message is returned to the sender with an
946 informative message.
</p>
948 <p> The
<a href=
"relocated.5.html">relocated(
5)
</a> database is searched after
<a href=
"transport.5.html">transport(
5)
</a>
949 table lookups, in anticipation of
<a href=
"transport.5.html">transport(
5)
</a> tables that
950 can replace one recipient address by a different one.
</p>
952 <p> Lookups of relocated users are disabled by default. To enable,
953 edit the
<a href=
"postconf.5.html#relocated_maps">relocated_maps
</a> parameter in the
<a href=
"postconf.5.html">main.cf
</a> file and specify
954 one or more lookup tables, separated by whitespace or commas.
</p>
960 /etc/postfix/
<a href=
"postconf.5.html">main.cf
</a>:
961 <a href=
"postconf.5.html#relocated_maps">relocated_maps
</a> = hash:/etc/postfix/relocated
963 /etc/postfix/relocated:
964 username@example.com otheruser@elsewhere.tld
968 <p> As of Postfix version
2, mail for a relocated user will be
969 rejected by the SMTP server with the reason
"user has moved to
970 otheruser@elsewhere.tld". Older Postfix versions will receive the
971 mail first, and then return it to the sender as undeliverable, with
972 the same reason.
</p>
974 <h3> <a name=
"generic"> Generic mapping for outgoing SMTP mail
</a> </h3>
976 <p> Some hosts have no valid Internet domain name, and instead use
977 a name such as
<i>localdomain.local
</i>. This can be a problem when
978 you want to send mail over the Internet, because many mail servers
979 reject mail addresses with invalid domain names.
</p>
981 <p> With the
<a href=
"postconf.5.html#smtp_generic_maps">smtp_generic_maps
</a> parameter you can specify
<a href=
"generic.5.html">generic(
5)
</a>
982 lookup tables that replace local mail addresses by valid Internet
983 addresses when mail leaves the machine via SMTP. The
<a href=
"generic.5.html">generic(
5)
</a>
984 mapping replaces envelope and header addresses, and is non-recursive.
985 It does not happen when you send mail between addresses on the
988 <p> This feature is available in Postfix version
2.2 and later.
</p>
994 /etc/postfix/
<a href=
"postconf.5.html">main.cf
</a>:
995 <a href=
"postconf.5.html#smtp_generic_maps">smtp_generic_maps
</a> = hash:/etc/postfix/generic
997 /etc/postfix/generic:
998 his@localdomain.local hisaccount@hisisp.example
999 her@localdomain.local heraccount@herisp.example
1000 @localdomain.local hisaccount+local@hisisp.example
1004 <p> When mail is sent to a remote host via SMTP, this replaces
1005 <i>his@localdomain.local
</i> by his ISP mail address, replaces
1006 <i>her@localdomain.local
</i> by her ISP mail address, and replaces
1007 other local addresses by his ISP account, with an address extension
1008 of +
<i>local
</i> (this example assumes that the ISP supports
"+"
1009 style address extensions).
</p>
1011 <h3> <a name=
"aliases"> Local alias database
</a> </h3>
1013 <p> When mail is to be delivered locally, the
<a href=
"local.8.html">local(
8)
</a> delivery
1014 agent runs each local recipient name through the
<a href=
"aliases.5.html">aliases(
5)
</a> database.
1015 The mapping does not affect addresses in message headers. Local
1016 aliases are typically used to implement distribution lists, or to
1017 direct mail for standard aliases such as postmaster to real people.
1018 The table can also be used to map
"Firstname.Lastname" addresses
1019 to login names.
</p>
1021 <p> Alias lookups are enabled by default. The default configuration
1022 depends on the operating system environment, but it is typically
1023 one of the following:
</p>
1027 /etc/postfix/
<a href=
"postconf.5.html">main.cf
</a>:
1028 <a href=
"postconf.5.html#alias_maps">alias_maps
</a> = hash:/etc/aliases
1029 <a href=
"postconf.5.html#alias_maps">alias_maps
</a> = dbm:/etc/aliases, nis:mail.aliases
1033 <p> The pathname of the alias database file is controlled with the
1034 <a href=
"postconf.5.html#alias_database">alias_database
</a> configuration parameter. The value is system dependent.
1035 Usually it is one of the following:
</p>
1039 /etc/postfix/
<a href=
"postconf.5.html">main.cf
</a>:
1040 <a href=
"postconf.5.html#alias_database">alias_database
</a> = hash:/etc/aliases (
4.4BSD, LINUX)
1041 <a href=
"postconf.5.html#alias_database">alias_database
</a> = dbm:/etc/aliases (
4.3BSD, SYSV
<4)
1042 <a href=
"postconf.5.html#alias_database">alias_database
</a> = dbm:/etc/mail/aliases (SYSV4)
1046 <p> An
<a href=
"aliases.5.html">aliases(
5)
</a> file can specify that mail should be delivered
1047 to a local file, or to a command that receives the message in the
1048 standard input stream. For security reasons, deliveries to command
1049 and file destinations are performed with the rights of the alias
1050 database owner. A default userid,
<a href=
"postconf.5.html#default_privs">default_privs
</a>, is used for
1051 deliveries to commands or files in
"root"-owned aliases.
</p>
1053 <h3> <a name=
"forward"> Local per-user .forward files
</a> </h3>
1055 <p> With delivery via the
<a href=
"local.8.html">local(
8)
</a> deliver agent, users can control
1056 their own mail delivery by specifying destinations in a file called
1057 .forward in their home directories. The syntax of these files is
1058 the same as with the local
<a href=
"aliases.5.html">aliases(
5)
</a> file, except that the left-hand
1059 side of the alias (lookup key and colon) are not present.
</p>
1061 <h3> <a name=
"luser_relay"> Local catch-all address
</a> </h3>
1063 <p> When the
<a href=
"local.8.html">local(
8)
</a> delivery agent finds that a message recipient
1064 does not exist, the message is normally returned to the sender (
"user
1065 unknown"). Sometimes it is desirable to forward mail for non-existing
1066 recipients to another machine. For this purpose you can specify
1067 an alternative destination with the
<a href=
"postconf.5.html#luser_relay">luser_relay
</a> configuration
1070 <p> Alternatively, mail for non-existent recipients can be delegated
1071 to an entirely different message transport, as specified with the
1072 <a href=
"postconf.5.html#fallback_transport">fallback_transport
</a> configuration parameter. For details, see the
1073 <a href=
"local.8.html">local(
8)
</a> delivery agent documentation.
</p>
1075 <p> Note: if you use the
<a href=
"postconf.5.html#luser_relay">luser_relay
</a> feature in order to receive
1076 mail for non-UNIX accounts, then you must specify:
</p>
1080 /etc/postfix/
<a href=
"postconf.5.html">main.cf
</a>:
1081 <a href=
"postconf.5.html#local_recipient_maps">local_recipient_maps
</a> =
1085 <p> (i.e. empty) in the
<a href=
"postconf.5.html">main.cf
</a> file, otherwise the Postfix SMTP
1086 server will reject mail for non-UNIX accounts with
"User unknown
1087 in local recipient table". See the
<a href=
"LOCAL_RECIPIENT_README.html">LOCAL_RECIPIENT_README
</a> file
1088 for more information on this.
1091 <p> <a href=
"postconf.5.html#luser_relay">luser_relay
</a> can specify one address. It is subjected to
"$name"
1092 expansions. Examples:
</p>
1098 <dt>$user@other.host
</dt>
1100 <dd> <p> The bare username, without address extension, is prepended
1101 to
"@other.host". For example, mail for
"username+foo" is sent to
1102 "username@other.host".
</p> </dd>
1104 <dt>$local@other.host
</dt>
1106 <dd> <p> The entire original recipient localpart, including address
1107 extension, is prepended to
"@other.host". For example, mail for
1108 "username+foo" is sent to
"username+foo@other.host".
</p> </dd>
1110 <dt>sysadmin+$user
</dt>
1112 <dd> <p> The bare username, without address extension, is appended
1113 to
"sysadmin". For example, mail for
"username+foo" is sent to
1114 "sysadmin+username".
</p> </dd>
1116 <dt>sysadmin+$local
</dt>
1118 <dd> <p> The entire original recipient localpart, including address
1119 extension, is appended to
"sysadmin". For example, mail for
1120 "username+foo" is sent to
"sysadmin+username+foo".
</p> </dd>
1126 <h2> <a name=
"debugging"> Debugging your address manipulations
</a> </h2>
1128 <p> Postfix version
2.1 and later can
1129 produce mail delivery reports for debugging purposes. These reports
1130 not only show sender/recipient addresses after address rewriting
1131 and alias expansion or forwarding, they also show information about
1132 delivery to mailbox, delivery to non-Postfix command, responses
1133 from remote SMTP servers, and so on.
</p>
1135 <p> Postfix can produce two types of mail delivery reports for
1140 <li> <p> What-if: report what would happen, but do not actually
1141 deliver mail. This mode of operation is requested with:
</p>
1144 $
<b>/usr/sbin/sendmail -bv address...
</b>
1145 Mail Delivery Status Report will be mailed to
<your login name
>.
1148 <li> <p> What happened: deliver mail and report successes and/or
1149 failures, including replies from remote SMTP servers. This mode
1150 of operation is requested with:
</p>
1153 $
<b>/usr/sbin/sendmail -v address...
</b>
1154 Mail Delivery Status Report will be mailed to
<your login name
>.
1159 <p> These reports contain information that is generated by Postfix
1160 delivery agents. Since these run as daemon processes and do not
1161 interact with users directly, the result is sent as mail to the
1162 sender of the test message. The format of these reports is practically
1163 identical to that of ordinary non-delivery notifications.
</p>
1165 <p> As an example, below is the delivery report that is produced
1166 with the command
"sendmail -bv postfix-users@postfix.org". The
1167 first part of the report contains human-readable text. In this
1168 case, mail would be delivered via mail.cloud9.net, and the SMTP
1169 server replies with
"250 Ok". Other reports may show delivery
1170 to mailbox, or delivery to non-Postfix command.
</p>
1174 Content-Description: Notification
1175 Content-Type: text/plain
1177 This is the mail system at host spike.porcupine.org.
1179 Enclosed is the mail delivery report that you requested.
1183 <postfix-users@postfix.org
>: delivery via mail.cloud9.net[
168.100.1.4]:
250 2.1.5 Ok
1187 <p> The second part of the report is in machine-readable form, and
1188 includes the following information:
</p>
1192 <li> The envelope sender address (wietse@porcupine.org).
1194 <li> The envelope recipient address (postfix-users@postfix.org).
1195 If the recipient address was changed by Postfix then Postfix also
1196 includes the original recipient address.
1198 <li> The delivery status.
1202 <p> Some details depend on Postfix version. The example below is
1203 for Postfix version
2.3 and later.
</p>
1207 Content-Description: Delivery report
1208 Content-Type: message/delivery-status
1210 Reporting-MTA: dns; spike.porcupine.org
1211 X-Postfix-Queue-ID:
84863BC0E5
1212 X-Postfix-Sender: rfc822; wietse@porcupine.org
1213 Arrival-Date: Sun,
26 Nov
2006 17:
01:
01 -
0500 (EST)
1215 Final-Recipient: rfc822; postfix-users@postfix.org
1218 Remote-MTA: dns; mail.cloud9.net
1219 Diagnostic-Code: smtp;
250 2.1.5 Ok
1223 <p> The third part of the report contains the message that Postfix
1224 would have delivered, including From: and To: message headers, so
1225 that you can see any effects of address rewriting on those. Mail
1226 submitted with
"sendmail -bv" has no body content so none is shown
1227 in the example below.
</p>
1231 Content-Description: Message
1232 Content-Type: message/rfc822
1234 Received: by spike.porcupine.org (Postfix, from userid
1001)
1235 id
84863BC0E5; Sun,
26 Nov
2006 17:
01:
01 -
0500 (EST)
1237 To: postfix-users@postfix.org
1238 Message-Id:
<20061126220101.84863BC0E5@spike.porcupine.org
>
1239 Date: Sun,
26 Nov
2006 17:
01:
01 -
0500 (EST)
1240 From: wietse@porcupine.org (Wietse Venema)