ADDRESS_REWRITING_README.html 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  1. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <title>Postfix Address Rewriting </title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
  7. </head>
  8. <body>
  9. <h1><img src="postfix-logo.jpg" width="203" height="98" ALT="">Postfix
  10. Address Rewriting </h1>
  11. <hr>
  12. <h2> <a name="purpose"> Postfix address rewriting purpose </a> </h2>
  13. <p> Address rewriting is at the heart of the Postfix mail system.
  14. Postfix rewrites addresses for many different purposes. Some are
  15. merely cosmetic, and some are necessary to deliver correctly
  16. formatted mail to the correct destination. Examples of
  17. address rewriting in Postfix are: </p>
  18. <ul>
  19. <li> <p> Transform an incomplete address into a complete address.
  20. For example, transform "username" into "username@example.com", or
  21. transform "username@hostname" into "username@hostname.example.com".
  22. </p>
  23. <li> <p> Replace an address by an equivalent address. For example,
  24. replace "username@example.com" by "firstname.lastname@example.com"
  25. when sending mail, and do the reverse transformation when receiving
  26. mail. </p>
  27. <li> <p> Replace an internal address by an external address. For
  28. example, replace "username@localdomain.local" by "isp-account@isp.example"
  29. when sending mail from a home computer to the Internet.
  30. </p>
  31. <li> <p> Replace an address by multiple addresses. For example,
  32. replace the address of an alias by the addresses listed under that
  33. alias. </p>
  34. <li> <p> Determine how and where to deliver mail for a specific
  35. address. For example, deliver mail for "username@example.com" with
  36. the <a href="smtp.8.html">smtp(8)</a> delivery agent, to the hosts that are listed in the
  37. DNS as the mail servers for the domain "example.com". </p>
  38. </ul>
  39. <p> Although Postfix currently has no address rewriting language,
  40. it can do surprisingly powerful address manipulation via table
  41. lookup. Postfix typically uses lookup tables with fixed strings
  42. to map one address to one or multiple addresses, and typically uses
  43. regular expressions to map multiple addresses to one or multiple
  44. addresses. Fixed-string lookup tables may be in the form of local
  45. files, or in the form of NIS, LDAP or SQL databases. The
  46. <a href="DATABASE_README.html">DATABASE_README</a> document gives an introduction to Postfix lookup
  47. tables. </p>
  48. <p> Topics covered in this document: </p>
  49. <ul>
  50. <li> <a href="#william"> To rewrite message headers or not, or to label
  51. as invalid </a>
  52. <li> <a href="#overview"> Postfix address rewriting overview </a>
  53. <li> <a href="#receiving"> Address rewriting when mail is received</a>
  54. <ul>
  55. <li> <a href="#standard"> Rewrite addresses to standard form</a>
  56. <li> <a href="#canonical"> Canonical address mapping </a>
  57. <li> <a href="#masquerade"> Address masquerading </a>
  58. <li> <a href="#auto_bcc"> Automatic BCC recipients</a>
  59. <li> <a href="#virtual"> Virtual aliasing </a>
  60. </ul>
  61. <li> <a href="#delivering"> Address rewriting when mail is delivered</a>
  62. <ul>
  63. <li> <a href="#resolve"> Resolve address to destination </a>
  64. <li> <a href="#transport"> Mail transport switch </a>
  65. <li> <a href="#relocated"> Relocated users table </a>
  66. </ul>
  67. <li> <a href="#remote"> Address rewriting with remote delivery </a>
  68. <ul>
  69. <li> <a href="#generic"> Generic mapping for outgoing SMTP mail </a>
  70. </ul>
  71. <li> <a href="#local"> Address rewriting with local delivery </a>
  72. <ul>
  73. <li> <a href="#aliases"> Local alias database </a>
  74. <li> <a href="#forward"> Local per-user .forward files </a>
  75. <li> <a href="#luser_relay"> Local catch-all address </a>
  76. </ul>
  77. <li> <a href="#debugging"> Debugging your address manipulations </a>
  78. </ul>
  79. <h2> <a name="william"> To rewrite message headers or not, or to label
  80. as invalid </a> </h2>
  81. <p> Postfix versions 2.1 and earlier always rewrite message header
  82. addresses, and append Postfix's own domain information to addresses
  83. that Postfix considers incomplete. While rewriting message header
  84. addresses is OK for mail with a local origin, it is undesirable
  85. for remote mail: </p>
  86. <ul>
  87. <li> Message header address rewriting is frowned upon by mail standards,
  88. <li> Appending Postfix's own domain produces incorrect results with
  89. some incomplete addresses,
  90. <li> Appending Postfix's own domain sometimes creates the appearance
  91. that spam is sent by local users.
  92. </ul>
  93. <p> Postfix versions 2.2 give you the option to either not rewrite
  94. message headers from remote SMTP clients at all, or to label
  95. incomplete addresses in such message headers as invalid. Here is
  96. how it works: </p>
  97. <ul>
  98. <li> Postfix always rewrites message headers from local SMTP clients
  99. and from the Postfix sendmail command, and appends its own domain
  100. to incomplete addresses. The <a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> parameter
  101. controls what SMTP clients Postfix considers local (by default,
  102. only local network interface addresses).
  103. <li> Postfix never rewrites message header addresses from remote
  104. SMTP clients when the <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> parameter value
  105. is empty (the default setting).
  106. <li> Otherwise, Postfix rewrites message headers from remote SMTP
  107. clients, and appends the <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> value to
  108. incomplete addresses. This feature can be used to append a reserved
  109. domain such as "domain.invalid", so that incomplete addresses cannot
  110. be mistaken for local addresses.
  111. </ul>
  112. <h2> <a name="overview"> Postfix address rewriting overview </a> </h2>
  113. <p> The figure below zooms in on those parts of Postfix that are most
  114. involved with address rewriting activity. See the <a href="OVERVIEW.html">OVERVIEW</a> document
  115. for an overview of the complete Postfix architecture. Names followed
  116. by a number are Postfix daemon programs, while unnumbered names
  117. represent Postfix queues or internal sources of mail messages. </p>
  118. <blockquote>
  119. <table>
  120. <tr>
  121. <td colspan="2"> </td>
  122. <td bgcolor="#f0f0ff" align="center"> <a href="trivial-rewrite.8.html">trivial-<br>rewrite(8)</a><br>(std
  123. form) </td>
  124. <td colspan="5"> </td>
  125. <td bgcolor="#f0f0ff" align="center"> <a href="trivial-rewrite.8.html">trivial-<br>rewrite(8)</a><br>(resolve)
  126. </td>
  127. </tr>
  128. <tr>
  129. <td colspan="2"> </td>
  130. <td align="center"><table><tr><td align="center"> ^<br> <tt> |
  131. </tt> </td><td align="center"> <tt> |<br>v </tt> </td></tr></table>
  132. <td colspan="5"> </td>
  133. <td align="center"><table><tr><td align="center"> ^<br> <tt> |
  134. </tt> </td><td align="center"> <tt> |<br>v </tt> </td></tr></table>
  135. <td colspan="2"> </td>
  136. </tr>
  137. <tr>
  138. <td bgcolor="#f0f0ff" align="center" valign="middle"> <a href="smtpd.8.html">smtpd(8)</a>
  139. </td>
  140. <td rowspan="3" align="center" valign="middle"> <tt> &gt;- </tt>
  141. </td>
  142. <td rowspan="3" bgcolor="#f0f0ff" align="center"> <a href="cleanup.8.html">cleanup(8)</a> </td>
  143. <td rowspan="3" align="center" valign="middle"> <tt> -&gt; </tt>
  144. </td>
  145. <td rowspan="3" bgcolor="#f0f0ff" align="center"> <a
  146. href="QSHAPE_README.html#incoming_queue"> incoming </a> </td>
  147. <td rowspan="3" align="center" valign="middle"> <tt> -&gt; </tt>
  148. </td>
  149. <td rowspan="3" bgcolor="#f0f0ff" align="center"> <a
  150. href="QSHAPE_README.html#active_queue"> active </a> </td>
  151. <td rowspan="3" align="center" valign="middle"> <tt> -&gt; </tt>
  152. </td>
  153. <td rowspan="3" bgcolor="#f0f0ff" align="center"> <a href="qmgr.8.html">qmgr(8)</a> </td>
  154. <td rowspan="3" align="center" valign="middle"> <tt> -&lt; </tt>
  155. </td>
  156. <td bgcolor="#f0f0ff" align="center" valign="middle">
  157. <a href="smtp.8.html">smtp(8)</a> </td>
  158. </tr>
  159. <tr>
  160. <td bgcolor="#f0f0ff" align="center" valign="middle">
  161. <a href="qmqpd.8.html">qmqpd(8)</a> </td>
  162. <td bgcolor="#f0f0ff" align="center" valign="middle"> <a href="lmtp.8.html">lmtp(8)</a> </td>
  163. </tr>
  164. <tr>
  165. <td bgcolor="#f0f0ff" align="center" valign="middle"> <a href="pickup.8.html">pickup(8)</a>
  166. </td>
  167. <td bgcolor="#f0f0ff" align="center" valign="middle"> <a href="local.8.html">local(8)</a>
  168. </td>
  169. </tr>
  170. <tr>
  171. <td colspan="2"> </td>
  172. <td align="center"> ^<br> <tt> | </tt> </td>
  173. <td colspan="3"> </td>
  174. <td align="center"><table><tr><td align="center"> ^<br> <tt> |
  175. </tt> </td><td align="center"> <tt> |<br>v </tt> </td></tr></table>
  176. <td colspan="4"> </td>
  177. </tr>
  178. <tr>
  179. <td colspan="2"> </td>
  180. <td align="center"> bounces<br> forwarding<br> notices</td>
  181. <td colspan="3"> </td>
  182. <td bgcolor="#f0f0ff" align="center"> <a
  183. href="QSHAPE_README.html#deferred_queue"> deferred </a>
  184. <td colspan="2"> </td>
  185. </table>
  186. </blockquote>
  187. <p> The table below summarizes all Postfix address manipulations.
  188. If you're reading this document for the first time, skip forward
  189. to "<a href="ADDRESS_REWRITING_README.html#receiving">Address
  190. rewriting when mail is received</a>". Once you've finished reading
  191. the remainder of this document, the table will help you to quickly
  192. find what you need. </p>
  193. <blockquote>
  194. <table border="1">
  195. <tr> <th nowrap> Address manipulation </th> <th nowrap> Scope </th>
  196. <th> Daemon </th> <th nowrap> Global turn-on control </th> <th nowrap> Selective
  197. turn-off control </th> </tr>
  198. <tr> <td> <a href="#standard"> Rewrite addresses to standard form</a>
  199. </td> <td nowrap> all mail </td> <td> <a href="trivial-rewrite.8.html">trivial-<br>rewrite(8)</a> </td>
  200. <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>,
  201. <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>,
  202. <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> </td> </tr>
  203. <tr> <td> <a href="#canonical"> Canonical address mapping </a> </td>
  204. <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>
  205. </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>,
  206. <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> </td> </tr>
  207. <tr> <td> <a href="#masquerade"> Address masquerading </a> </td> <td
  208. 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>
  209. </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>,
  210. <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> </td> </tr>
  211. <tr> <td> <a href="#auto_bcc"> Automatic BCC recipients </a> </td>
  212. <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>,
  213. <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>
  214. </td> </tr>
  215. <tr> <td> <a href="#virtual"> Virtual aliasing </a> </td> <td
  216. 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>
  217. </td> <td> <a href="postconf.5.html#receive_override_options">receive_override_options</a> </td> </tr>
  218. <tr> <td> <a href="#resolve"> Resolve address to destination </a>
  219. </td> <td nowrap> all mail </td> <td> <a href="trivial-rewrite.8.html">trivial-<br>rewrite(8)</a> </td>
  220. <td> none </td> <td> none </td> </tr>
  221. <tr> <td> <a href="#transport"> Mail transport switch</a> </td>
  222. <td nowrap> all mail </td> <td> <a href="trivial-rewrite.8.html">trivial-<br>rewrite(8)</a> </td> <td>
  223. <a href="postconf.5.html#transport_maps">transport_maps</a> </td> <td> none </td> </tr>
  224. <tr> <td> <a href="#relocated"> Relocated users table</a> </td>
  225. <td nowrap> all mail </td> <td> <a href="trivial-rewrite.8.html">trivial-<br>rewrite(8)</a> </td> <td>
  226. <a href="postconf.5.html#relocated_maps">relocated_maps</a> </td> <td> none </td> </tr>
  227. <tr> <td> <a href="#generic"> Generic mapping table </a> </td> <td>
  228. 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>
  229. </td> <td> none </td> </tr>
  230. <tr> <td> <a href="#aliases"> Local alias database</a> </td> <td>
  231. 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
  232. </td> </tr>
  233. <tr> <td> <a href="#forward"> Local per-user .forward files</a>
  234. </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>
  235. </td> <td> none </td> </tr>
  236. <tr> <td> <a href="#luser_relay"> Local catch-all address</a> </td>
  237. <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>
  238. none </td> </tr>
  239. </table>
  240. </blockquote>
  241. <h2> <a name="receiving"> Address rewriting when mail is received</a>
  242. </h2>
  243. <p> The <a href="cleanup.8.html">cleanup(8)</a> server receives mail from outside of Postfix as
  244. well as mail from internal sources such as forwarded mail,
  245. undeliverable mail that is bounced to the sender, and postmaster
  246. notifications about problems with the mail system. </p>
  247. <p> The <a href="cleanup.8.html">cleanup(8)</a> server transforms the sender, recipients and
  248. message content into a standard form before writing it to an incoming
  249. queue file. The server cleans up sender and recipient addresses in
  250. message headers and in the envelope, adds missing message headers
  251. such as From: or Date: that are required by mail standards, and
  252. removes message headers such as Bcc: that should not be present.
  253. The <a href="cleanup.8.html">cleanup(8)</a> server delegates the more complex address manipulations
  254. to the <a href="trivial-rewrite.8.html">trivial-rewrite(8)</a> server as described later in this document.
  255. </p>
  256. <p> Address manipulations at this stage are: </p>
  257. <ul>
  258. <li> <a href="#standard"> Rewrite addresses to standard form</a>
  259. <li> <a href="#canonical"> Canonical address mapping</a>
  260. <li> <a href="#masquerade"> Address masquerading</a>
  261. <li> <a href="#auto_bcc"> Automatic BCC recipients</a>
  262. <li> <a href="#virtual"> Virtual aliasing </a>
  263. </ul>
  264. <h3> <a name="standard"> Rewrite addresses to standard form</a> </h3>
  265. <p> Before the <a href="cleanup.8.html">cleanup(8)</a> daemon runs an address through any address
  266. mapping lookup table, it first rewrites the address to the standard
  267. "user@fully.qualified.domain" form, by sending the address to the
  268. <a href="trivial-rewrite.8.html">trivial-rewrite(8)</a> daemon. The purpose of rewriting to standard
  269. form is to reduce the number of entries needed in lookup tables.
  270. </p>
  271. <p> The Postfix <a href="trivial-rewrite.8.html">trivial-rewrite(8)</a> daemon implements the following
  272. hard-coded address manipulations: </p>
  273. <blockquote>
  274. <dl>
  275. <dt>Rewrite "@hosta,@hostb:user@site" to "user@site"</dt>
  276. <dd> <p> In case you wonder what this is, the address form above
  277. is called a route address, and specifies that mail for "user@site"
  278. be delivered via "hosta" and "hostb". Usage of this form has been
  279. deprecated for a long time. Postfix has no ability to handle route
  280. addresses, other than to strip off the route part. </p>
  281. <p> NOTE: Postfix versions 2.2 and later rewrite message headers
  282. from remote SMTP clients only if the client matches the
  283. <a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> parameter, or if the
  284. <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> configuration parameter specifies a
  285. non-empty value. To get the behavior before Postfix 2.2, specify
  286. "<a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> = <a href="DATABASE_README.html#types">static</a>:all". </p> </dd>
  287. <dt>Rewrite "site!user" to "user@site" </dt>
  288. <dd> <p> This feature is controlled by the boolean <a href="postconf.5.html#swap_bangpath">swap_bangpath</a>
  289. parameter (default: yes). The purpose is to rewrite UUCP-style
  290. addresses to domain style. This is useful only when you receive
  291. mail via UUCP, but it probably does not hurt otherwise. </p>
  292. <p> NOTE: Postfix versions 2.2 and later rewrite message headers
  293. from remote SMTP clients only if the client matches the
  294. <a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> parameter, or if the
  295. <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> configuration parameter specifies a
  296. non-empty value. To get the behavior before Postfix 2.2, specify
  297. "<a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> = <a href="DATABASE_README.html#types">static</a>:all". </p> </dd>
  298. <dt>Rewrite "user%domain" to "user@domain"</dt>
  299. <dd> <p> This feature is controlled by the boolean <a href="postconf.5.html#allow_percent_hack">allow_percent_hack</a>
  300. parameter (default: yes). Typically, this is used in order to deal
  301. with monstrosities such as "user%domain@otherdomain". </p>
  302. <p> NOTE: Postfix versions 2.2 and later rewrite message headers
  303. from remote SMTP clients only if the client matches the
  304. <a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> parameter, or if the
  305. <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> configuration parameter specifies a
  306. non-empty value. To get the behavior before Postfix 2.2, specify
  307. "<a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> = <a href="DATABASE_README.html#types">static</a>:all". </p> </dd>
  308. <dt>
  309. Rewrite "user" to "user@$<a href="postconf.5.html#myorigin">myorigin</a>" </dt>
  310. <dd> <p> This feature is controlled by the boolean <a href="postconf.5.html#append_at_myorigin">append_at_myorigin</a>
  311. parameter (default: yes). You should never turn off this feature,
  312. because a lot of Postfix components expect that all addresses have
  313. the form "user@domain". </p>
  314. <p> NOTE: Postfix versions 2.2 and later rewrite message headers
  315. from remote SMTP clients only if the client matches the
  316. <a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> parameter; otherwise they append the
  317. domain name specified with the <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a>
  318. configuration parameter, if one is specified. To get the behavior
  319. before Postfix 2.2, specify "<a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> =
  320. <a href="DATABASE_README.html#types">static</a>:all". </p>
  321. <p> If your machine is not the main machine for $<a href="postconf.5.html#myorigin">myorigin</a> and you
  322. wish to have some users delivered locally without going via that
  323. main machine, make an entry in the <a href="#virtual">virtual
  324. alias</a> table that redirects "user@$myorigin" to
  325. "user@$<a href="postconf.5.html#myhostname">myhostname</a>". See also the "delivering some
  326. users locally" section in the <a href="STANDARD_CONFIGURATION_README.html">STANDARD_CONFIGURATION_README</a>
  327. document. </p> </dd>
  328. <dt>
  329. Rewrite "user@host" to "user@host.$<a href="postconf.5.html#mydomain">mydomain</a>" </dt>
  330. <dd> <p> This feature is controlled by the boolean <a href="postconf.5.html#append_dot_mydomain">append_dot_mydomain</a>
  331. parameter (default: yes). The purpose is to get consistent treatment
  332. of different forms of the same hostname. </p>
  333. <p> NOTE: Postfix versions 2.2 and later rewrite message headers
  334. from remote SMTP clients only if the client matches the
  335. <a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> parameter; otherwise they append the
  336. domain name specified with the <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a>
  337. configuration parameter, if one is specified. To get the behavior
  338. before Postfix 2.2, specify "<a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> =
  339. <a href="DATABASE_README.html#types">static</a>:all". </p>
  340. <p> Some will argue that rewriting "host" to "host.domain"
  341. is bad. That is why it can be turned off. Others like the convenience
  342. of having Postfix's own domain appended automatically. </p> </dd>
  343. <dt>Rewrite "user@site." to "user@site" (without the trailing dot).</dt>
  344. <dd> <p> A single trailing dot is silently removed. However, an
  345. address that ends in multiple dots will be rejected as an invalid
  346. address. </p>
  347. <p> NOTE: Postfix versions 2.2 and later rewrite message headers
  348. from remote SMTP clients only if the client matches the
  349. <a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> parameter, or if the
  350. <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> configuration parameter specifies a
  351. non-empty value. To get the behavior before Postfix 2.2, specify
  352. "<a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> = <a href="DATABASE_README.html#types">static</a>:all". </p> </dd>
  353. </dl>
  354. </blockquote>
  355. <h3> <a name="canonical"> Canonical address mapping </a> </h3>
  356. <p> The <a href="cleanup.8.html">cleanup(8)</a> daemon uses the <a href="canonical.5.html">canonical(5)</a> tables to rewrite
  357. addresses in message envelopes and in message headers. By default
  358. all header and envelope addresses are rewritten; this is controlled
  359. with the <a href="postconf.5.html#canonical_classes">canonical_classes</a> configuration parameter. </p>
  360. <p> NOTE: Postfix versions 2.2 and later rewrite message headers
  361. from remote SMTP clients only if the client matches the
  362. <a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> parameter, or if the
  363. <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> configuration parameter specifies a
  364. non-empty value. To get the behavior before Postfix 2.2, specify
  365. "<a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> = <a href="DATABASE_README.html#types">static</a>:all". </p>
  366. <p> Address rewriting is
  367. done for local and remote addresses. The mapping is useful to
  368. replace login names by "Firstname.Lastname" style addresses, or to
  369. clean up invalid domains in mail addresses produced by legacy mail
  370. systems. </p>
  371. <p> Canonical mapping is disabled by default. To enable, edit the
  372. <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
  373. more lookup tables, separated by whitespace or commas. </p>
  374. <p> Example: </p>
  375. <blockquote>
  376. <pre>
  377. /etc/postfix/<a href="postconf.5.html">main.cf</a>:
  378. <a href="postconf.5.html#canonical_maps">canonical_maps</a> = <a href="DATABASE_README.html#types">hash</a>:/etc/postfix/canonical
  379. /etc/postfix/canonical:
  380. wietse Wietse.Venema
  381. </pre>
  382. </blockquote>
  383. <p> For static mappings as shown above, lookup tables such as <a href="DATABASE_README.html#types">hash</a>:,
  384. <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
  385. can use regular expression tables. This requires that you become
  386. intimately familiar with the ideas expressed in <a href="regexp_table.5.html">regexp_table(5)</a>,
  387. <a href="pcre_table.5.html">pcre_table(5)</a> and <a href="canonical.5.html">canonical(5)</a>. </p>
  388. <p> In addition to the canonical maps which are applied to both sender
  389. and recipient addresses, you can specify canonical maps that are
  390. applied only to sender addresses or to recipient addresses. </p>
  391. <p> Example: </p>
  392. <blockquote>
  393. <pre>
  394. /etc/postfix/<a href="postconf.5.html">main.cf</a>:
  395. <a href="postconf.5.html#sender_canonical_maps">sender_canonical_maps</a> = <a href="DATABASE_README.html#types">hash</a>:/etc/postfix/sender_canonical
  396. <a href="postconf.5.html#recipient_canonical_maps">recipient_canonical_maps</a> = <a href="DATABASE_README.html#types">hash</a>:/etc/postfix/recipient_canonical
  397. </pre>
  398. </blockquote>
  399. <p> The sender and recipient canonical maps are applied before the
  400. common canonical maps. The <a href="postconf.5.html#sender_canonical_classes">sender_canonical_classes</a> and
  401. <a href="postconf.5.html#recipient_canonical_classes">recipient_canonical_classes</a> parameters control what addresses are
  402. 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>
  403. mappings, respectively. </p>
  404. <p> Sender-specific rewriting is useful when you want to rewrite
  405. ugly sender addresses to pretty ones, and still want to be able to
  406. send mail to the those ugly address without creating a mailer loop.
  407. </p>
  408. <p> Canonical mapping can be turned off selectively for mail received
  409. 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
  410. in the <a href="master.5.html">master.cf</a> file. This feature is available in Postfix version
  411. 2.1 and later. </p>
  412. <p> Example: </p>
  413. <blockquote>
  414. <pre>
  415. /etc/postfix/<a href="master.5.html">master.cf</a>:
  416. 127.0.0.1:10026 inet n - n - - smtpd
  417. -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>
  418. </pre>
  419. </blockquote>
  420. <p> Note: do not specify whitespace around the "=" here. </p>
  421. <h3> <a name="masquerade"> Address masquerading </a> </h3>
  422. <p> Address masquerading is a method to hide hosts inside a domain
  423. behind their mail gateway, and to make it appear as if the mail
  424. comes from the gateway itself, instead of from individual machines.
  425. </p>
  426. <p> NOTE: Postfix versions 2.2 and later rewrite message headers
  427. from remote SMTP clients only if the client matches the
  428. <a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> parameter, or if the
  429. <a href="postconf.5.html#remote_header_rewrite_domain">remote_header_rewrite_domain</a> configuration parameter specifies a
  430. non-empty value. To get the behavior before Postfix 2.2, specify
  431. "<a href="postconf.5.html#local_header_rewrite_clients">local_header_rewrite_clients</a> = <a href="DATABASE_README.html#types">static</a>:all". </p>
  432. <p> Address masquerading is disabled by default, and is implemented
  433. 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>
  434. parameter in the <a href="postconf.5.html">main.cf</a> file and specify one or more domain names
  435. separated by whitespace or commas. When Postfix tries to masquerade
  436. a domain, it processes the list from left to right, and processing
  437. stops at the first match. </p>
  438. <p> Example: </p>
  439. <blockquote>
  440. <pre>
  441. /etc/postfix/<a href="postconf.5.html">main.cf</a>:
  442. <a href="postconf.5.html#masquerade_domains">masquerade_domains</a> = foo.example.com example.com
  443. </pre>
  444. </blockquote>
  445. <p> strips "any.thing.foo.example.com" to "foo.example.com", but
  446. strips "any.thing.else.example.com" to "example.com". </p>
  447. <p> A domain name prefixed with "<tt>!</tt>" means do not masquerade
  448. this domain or its subdomains: </p>
  449. <blockquote>
  450. <pre>
  451. /etc/postfix/<a href="postconf.5.html">main.cf</a>:
  452. <a href="postconf.5.html#masquerade_domains">masquerade_domains</a> = !foo.example.com example.com
  453. </pre>
  454. </blockquote>
  455. <p> does not change "any.thing.foo.example.com" and "foo.example.com",
  456. but strips "any.thing.else.example.com" to "example.com". </p>
  457. <p> The <a href="postconf.5.html#masquerade_exceptions">masquerade_exceptions</a> configuration parameter specifies
  458. what user names should not be subjected to address masquerading.
  459. Specify one or more user names separated by whitespace or commas.
  460. </p>
  461. <p> Example: </p>
  462. <blockquote>
  463. <pre>
  464. /etc/postfix/<a href="postconf.5.html">main.cf</a>:
  465. <a href="postconf.5.html#masquerade_exceptions">masquerade_exceptions</a> = root
  466. </pre>
  467. </blockquote>
  468. <p> By default, Postfix makes no exceptions. </p>
  469. <p> Subtle point: by default, address masquerading is applied only to
  470. message headers and to envelope sender addresses, but not to envelope
  471. recipients. This allows you to use address masquerading on a mail
  472. gateway machine, while still being able to forward mail from outside
  473. to users on individual machines. </p>
  474. <p> In order to subject envelope recipient addresses to masquerading,
  475. too, specify (Postfix version 1.1 and later):</p>
  476. <blockquote>
  477. <pre>
  478. /etc/postfix/<a href="postconf.5.html">main.cf</a>:
  479. <a href="postconf.5.html#masquerade_classes">masquerade_classes</a> = envelope_sender, envelope_recipient,
  480. header_sender, header_recipient
  481. </pre>
  482. </blockquote>
  483. <p> If you rewrite the envelope recipient like this, Postfix will
  484. no longer be able to send mail to individual machines. </p>
  485. <p> Address masquerading can be turned off selectively for mail
  486. 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>
  487. settings in the <a href="master.5.html">master.cf</a> file. This feature is available in
  488. Postfix version 2.1 and later. </p>
  489. <p> Example: </p>
  490. <blockquote>
  491. <pre>
  492. /etc/postfix/<a href="master.5.html">master.cf</a>:
  493. 127.0.0.1:10026 inet n - n - - smtpd
  494. -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>
  495. </pre>
  496. </blockquote>
  497. <p> Note: do not specify whitespace around the "=" here. </p>
  498. <h3> <a name="auto_bcc"> Automatic BCC recipients</a> </h3>
  499. <p> After applying the canonical and masquerade mappings, the
  500. <a href="cleanup.8.html">cleanup(8)</a> daemon can generate optional BCC (blind carbon-copy)
  501. recipients. Postfix provides three mechanisms: </p>
  502. <blockquote>
  503. <dl>
  504. <dt> <a href="postconf.5.html#always_bcc">always_bcc</a> = address </dt> <dd> Deliver a copy of all mail to
  505. the specified address. In Postfix versions before 2.1, this feature
  506. 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>
  507. <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
  508. "<a href="DATABASE_README.html">type:table</a>" lookup table with the envelope sender address for an
  509. automatic BCC address. This feature is available in Postfix 2.1
  510. and later. </dd>
  511. <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
  512. "<a href="DATABASE_README.html">type:table</a>" lookup table with the envelope recipient address for
  513. an automatic BCC address. This feature is available in Postfix 2.1
  514. and later. </dd>
  515. </dl>
  516. </blockquote>
  517. <p> Note: automatic BCC recipients are produced only for new mail.
  518. To avoid mailer loops, automatic BCC recipients are not generated
  519. for mail that Postfix forwards internally, nor for mail that Postfix
  520. generates itself. </p>
  521. <p> Automatic BCC recipients (including <a href="postconf.5.html#always_bcc">always_bcc</a>) can be turned
  522. 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>,
  523. by overriding <a href="postconf.5.html">main.cf</a> settings in the <a href="master.5.html">master.cf</a> file. This feature
  524. is available in Postfix version 2.1 and later. </p>
  525. <p> Example: </p>
  526. <blockquote>
  527. <pre>
  528. /etc/postfix/<a href="master.5.html">master.cf</a>:
  529. 127.0.0.1:10026 inet n - n - - smtpd
  530. -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>
  531. </pre>
  532. </blockquote>
  533. <p> Note: do not specify whitespace around the "=" here. </p>
  534. <h3> <a name="virtual"> Virtual aliasing </a> </h3>
  535. <p> Before writing the recipients to the queue file, the <a href="cleanup.8.html">cleanup(8)</a>
  536. daemon uses the optional <a href="virtual.5.html">virtual(5)</a> alias tables to redirect mail
  537. for recipients. The mapping affects only envelope recipient
  538. addresses; it has no effect on message headers or envelope sender
  539. addresses. Virtual alias lookups are useful to redirect mail for
  540. <a href="ADDRESS_CLASS_README.html#virtual_alias_class">virtual alias domains</a> to real user mailboxes, and to redirect mail
  541. for domains that no longer exist. Virtual alias lookups can also
  542. be used to transform " Firstname.Lastname " back into UNIX login
  543. names, although it seems that local <a href="#aliases">aliases</a>
  544. may be a more appropriate vehicle. See the <a href="VIRTUAL_README.html">VIRTUAL_README</a> document
  545. for an overview of methods to host virtual domains with Postfix.
  546. </p>
  547. <p> Virtual aliasing is disabled by default. To enable, edit the
  548. <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
  549. specify one or more lookup tables, separated by whitespace or
  550. commas. </p>
  551. <p> Example: </p>
  552. <blockquote>
  553. <pre>
  554. /etc/postfix/<a href="postconf.5.html">main.cf</a>:
  555. <a href="postconf.5.html#virtual_alias_maps">virtual_alias_maps</a> = <a href="DATABASE_README.html#types">hash</a>:/etc/postfix/virtual
  556. /etc/postfix/virtual:
  557. Wietse.Venema wietse
  558. </pre>
  559. </blockquote>
  560. <p> Addresses found in virtual alias maps are subjected to another
  561. iteration of virtual aliasing, but are not subjected to canonical
  562. mapping, in order to avoid loops. </p>
  563. <p> For static mappings as shown above, lookup tables such as <a href="DATABASE_README.html#types">hash</a>:,
  564. <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
  565. can use regular expression tables. This requires that you become
  566. intimately familiar with the ideas expressed in <a href="regexp_table.5.html">regexp_table(5)</a>,
  567. <a href="pcre_table.5.html">pcre_table(5)</a> and <a href="virtual.5.html">virtual(5)</a>. </p>
  568. <p> Virtual aliasing can be turned off selectively for mail received
  569. 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
  570. in the <a href="master.5.html">master.cf</a> file. This feature is available in Postfix version
  571. 2.1 and later. </p>
  572. <p> Example: </p>
  573. <blockquote>
  574. <pre>
  575. /etc/postfix/<a href="master.5.html">master.cf</a>:
  576. 127.0.0.1:10026 inet n - n - - smtpd
  577. -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>
  578. </pre>
  579. </blockquote>
  580. <p> Note: do not specify whitespace around the "=" here. </p>
  581. <p> At this point the message is ready to be stored into the
  582. Postfix <a href="QSHAPE_README.html#incoming_queue">incoming queue</a>. </p>
  583. <h2> <a name="delivering"> Address rewriting when mail is delivered</a> </h2>
  584. <p> The Postfix queue manager sorts mail according to its destination
  585. 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>,
  586. or <a href="lmtp.8.html">lmtp(8)</a>. Just like the <a href="cleanup.8.html">cleanup(8)</a> server, the Postfix queue
  587. manager delegates the more complex address manipulations to the
  588. <a href="trivial-rewrite.8.html">trivial-rewrite(8)</a> server. </p>
  589. <p> Address manipulations at this stage are: </p>
  590. <ul>
  591. <li> <a href="#resolve"> Resolve address to destination </a>
  592. <li> <a href="#transport"> Mail transport switch</a>
  593. <li> <a href="#relocated"> Relocated users table</a>
  594. </ul>
  595. <p> Each Postfix delivery agent tries to deliver the mail to its
  596. destination, while encapsulating the sender, recipients, and message
  597. content according to the rules of the SMTP, LMTP, etc. protocol.
  598. When mail cannot be delivered, it is either returned to the sender
  599. or moved to the <a href="QSHAPE_README.html#deferred_queue">deferred queue</a> and tried again later. </p>
  600. <p> <a name="remote">Address</a> manipulations when mail is delivered
  601. via the <a href="smtp.8.html">smtp(8)</a> delivery agent: </p>
  602. <ul>
  603. <li> <a href="#generic"> Generic mapping for outgoing SMTP mail </a>
  604. </ul>
  605. <p> <a name="local">Address</a> manipulations when mail is delivered
  606. via the <a href="local.8.html">local(8)</a> delivery agent: </p>
  607. <ul>
  608. <li> <a href="#aliases"> Local alias database</a>
  609. <li> <a href="#forward"> Local per-user .forward files</a>
  610. <li> <a href="#luser_relay"> Local catch-all address</a>
  611. </ul>
  612. <p> The remainder of this document presents each address manipulation
  613. step in more detail, with specific examples or with pointers to
  614. documentation with examples. </p>
  615. <h3> <a name="resolve"> Resolve address to destination </a> </h3>
  616. <p> The Postfix <a href="qmgr.8.html">qmgr(8)</a> queue manager selects new mail from the
  617. <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
  618. <a href="trivial-rewrite.8.html">trivial-rewrite(8)</a> address rewriting and resolving daemon where it
  619. should be delivered. </p>
  620. <p> As of version 2.0, Postfix distinguishes four major address
  621. classes. Each class has its own list of domain names, and each
  622. class has its own default delivery method, as shown in the table
  623. below. See the <a href="ADDRESS_CLASS_README.html">ADDRESS_CLASS_README</a> document for the fine details.
  624. Postfix versions before 2.0 only distinguish between local delivery
  625. and everything else. </p>
  626. <blockquote>
  627. <table border="1">
  628. <tr><th align="left">Destination domain list </th> <th
  629. align="left">Default delivery method </th> <th>Availability
  630. </th> </tr>
  631. <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>
  632. <td>$<a href="postconf.5.html#local_transport">local_transport</a> </td> <td>Postfix 1.0</td></tr>
  633. <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>
  634. <td>Postfix 2.0</td> </tr>
  635. <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
  636. 2.0</td> </tr>
  637. <tr><td>none </td> <td>$<a href="postconf.5.html#default_transport">default_transport</a> </td> <td>Postfix 1.0</td>
  638. </tr>
  639. </table>
  640. </blockquote>
  641. <h3> <a name="transport"> Mail transport switch </a> </h3>
  642. <p> Once the <a href="trivial-rewrite.8.html">trivial-rewrite(8)</a> daemon has determined a default
  643. delivery method it searches the optional <a href="transport.5.html">transport(5)</a> table for
  644. information that overrides the message destination and/or delivery
  645. method. Typical use of the <a href="transport.5.html">transport(5)</a> table is to send mail to
  646. a system
  647. that is not connected to the Internet, or to use a special SMTP
  648. client configuration for destinations that have special requirements.
  649. See, for example, the <a href="STANDARD_CONFIGURATION_README.html">STANDARD_CONFIGURATION_README</a> and <a href="UUCP_README.html">UUCP_README</a>
  650. documents, and the examples in the <a href="transport.5.html">transport(5)</a> manual page. </p>
  651. <p> Transport table lookups are disabled by default. To enable,
  652. 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
  653. one or more lookup tables, separated by whitespace or commas. </p>
  654. <p> Example: </p>
  655. <blockquote>
  656. <pre>
  657. /etc/postfix/<a href="postconf.5.html">main.cf</a>:
  658. <a href="postconf.5.html#transport_maps">transport_maps</a> = <a href="DATABASE_README.html#types">hash</a>:/etc/postfix/transport
  659. </pre>
  660. </blockquote>
  661. <h3> <a name="relocated"> Relocated users table </a> </h3>
  662. <p> Next, the <a href="trivial-rewrite.8.html">trivial-rewrite(8)</a> address rewriting and resolving
  663. daemon runs each recipient through the <a href="relocated.5.html">relocated(5)</a> database. This
  664. table provides information on how to reach users that no longer
  665. have an account, or what to do with mail for entire domains that
  666. no longer exist. When mail is sent to an address that is listed
  667. in this table, the message is returned to the sender with an
  668. informative message. </p>
  669. <p> The <a href="relocated.5.html">relocated(5)</a> database is searched after <a href="transport.5.html">transport(5)</a>
  670. table lookups, in anticipation of <a href="transport.5.html">transport(5)</a> tables that
  671. can replace one recipient address by a different one. </p>
  672. <p> Lookups of relocated users are disabled by default. To enable,
  673. 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
  674. one or more lookup tables, separated by whitespace or commas. </p>
  675. <p> Example: </p>
  676. <blockquote>
  677. <pre>
  678. /etc/postfix/<a href="postconf.5.html">main.cf</a>:
  679. <a href="postconf.5.html#relocated_maps">relocated_maps</a> = <a href="DATABASE_README.html#types">hash</a>:/etc/postfix/relocated
  680. /etc/postfix/relocated:
  681. username@example.com otheruser@elsewhere.tld
  682. </pre>
  683. </blockquote>
  684. <p> As of Postfix version 2, mail for a relocated user will be
  685. rejected by the SMTP server with the reason "user has moved to
  686. otheruser@elsewhere.tld". Older Postfix versions will receive the
  687. mail first, and then return it to the sender as undeliverable, with
  688. the same reason. </p>
  689. <h3> <a name="generic"> Generic mapping for outgoing SMTP mail </a> </h3>
  690. <p> Some hosts have no valid Internet domain name, and instead use
  691. a name such as <i>localdomain.local</i>. This can be a problem when
  692. you want to send mail over the Internet, because many mail servers
  693. reject mail addresses with invalid domain names. </p>
  694. <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>
  695. lookup tables that replace local mail addresses by valid Internet
  696. addresses when mail leaves the machine via SMTP. The <a href="generic.5.html">generic(5)</a>
  697. mapping replaces envelope and header addresses, and is non-recursive.
  698. It does not happen when you send mail between addresses on the
  699. local machine. </p>
  700. <p> This feature is available in Postfix version 2.2 and later.</p>
  701. <p> Example: </p>
  702. <blockquote>
  703. <pre>
  704. /etc/postfix/<a href="postconf.5.html">main.cf</a>:
  705. <a href="postconf.5.html#smtp_generic_maps">smtp_generic_maps</a> = <a href="DATABASE_README.html#types">hash</a>:/etc/postfix/generic
  706. /etc/postfix/generic:
  707. his@localdomain.local hisaccount@hisisp.example
  708. her@localdomain.local heraccount@herisp.example
  709. @localdomain.local hisaccount+local@hisisp.example
  710. </pre>
  711. </blockquote>
  712. <p> When mail is sent to a remote host via SMTP, this replaces
  713. <i>his@localdomain.local</i> by his ISP mail address, replaces
  714. <i>her@localdomain.local</i> by her ISP mail address, and replaces
  715. other local addresses by his ISP account, with an address extension
  716. of +<i>local</i> (this example assumes that the ISP supports "+"
  717. style address extensions). </p>
  718. <h3> <a name="aliases"> Local alias database </a> </h3>
  719. <p> When mail is to be delivered locally, the <a href="local.8.html">local(8)</a> delivery
  720. agent runs each local recipient name through the <a href="aliases.5.html">aliases(5)</a> database.
  721. The mapping does not affect addresses in message headers. Local
  722. aliases are typically used to implement distribution lists, or to
  723. direct mail for standard aliases such as postmaster to real people.
  724. The table can also be used to map "Firstname.Lastname" addresses
  725. to login names. </p>
  726. <p> Alias lookups are enabled by default. The default configuration
  727. depends on the operating system environment, but it is typically
  728. one of the following: </p>
  729. <blockquote>
  730. <pre>
  731. /etc/postfix/<a href="postconf.5.html">main.cf</a>:
  732. <a href="postconf.5.html#alias_maps">alias_maps</a> = <a href="DATABASE_README.html#types">hash</a>:/etc/aliases
  733. <a href="postconf.5.html#alias_maps">alias_maps</a> = <a href="DATABASE_README.html#types">dbm</a>:/etc/aliases, nis:mail.aliases
  734. </pre>
  735. </blockquote>
  736. <p> The pathname of the alias database file is controlled with the
  737. <a href="postconf.5.html#alias_database">alias_database</a> configuration parameter. The value is system dependent.
  738. Usually it is one of the following: </p>
  739. <blockquote>
  740. <pre>
  741. /etc/postfix/<a href="postconf.5.html">main.cf</a>:
  742. <a href="postconf.5.html#alias_database">alias_database</a> = <a href="DATABASE_README.html#types">hash</a>:/etc/aliases (4.4BSD, LINUX)
  743. <a href="postconf.5.html#alias_database">alias_database</a> = <a href="DATABASE_README.html#types">dbm</a>:/etc/aliases (4.3BSD, SYSV&lt;4)
  744. <a href="postconf.5.html#alias_database">alias_database</a> = <a href="DATABASE_README.html#types">dbm</a>:/etc/mail/aliases (SYSV4)
  745. </pre>
  746. </blockquote>
  747. <p> An <a href="aliases.5.html">aliases(5)</a> file can specify that mail should be delivered
  748. to a local file, or to a command that receives the message in the
  749. standard input stream. For security reasons, deliveries to command
  750. and file destinations are performed with the rights of the alias
  751. database owner. A default userid, <a href="postconf.5.html#default_privs">default_privs</a>, is used for
  752. deliveries to commands or files in "root"-owned aliases. </p>
  753. <h3> <a name="forward"> Local per-user .forward files </a> </h3>
  754. <p> With delivery via the <a href="local.8.html">local(8)</a> delivery agent, users can control
  755. their own mail delivery by specifying destinations in a file called
  756. .forward in their home directories. The syntax of these files is
  757. the same as with the local <a href="aliases.5.html">aliases(5)</a> file, except that the left-hand
  758. side of the alias (lookup key and colon) are not present. </p>
  759. <h3> <a name="luser_relay"> Local catch-all address </a> </h3>
  760. <p> When the <a href="local.8.html">local(8)</a> delivery agent finds that a message recipient
  761. does not exist, the message is normally returned to the sender ("user
  762. unknown"). Sometimes it is desirable to forward mail for non-existing
  763. recipients to another machine. For this purpose you can specify
  764. an alternative destination with the <a href="postconf.5.html#luser_relay">luser_relay</a> configuration
  765. parameter. </p>
  766. <p> Alternatively, mail for non-existent recipients can be delegated
  767. to an entirely different message transport, as specified with the
  768. <a href="postconf.5.html#fallback_transport">fallback_transport</a> configuration parameter. For details, see the
  769. <a href="local.8.html">local(8)</a> delivery agent documentation. </p>
  770. <p> Note: if you use the <a href="postconf.5.html#luser_relay">luser_relay</a> feature in order to receive
  771. mail for non-UNIX accounts, then you must specify: </p>
  772. <blockquote>
  773. <pre>
  774. /etc/postfix/<a href="postconf.5.html">main.cf</a>:
  775. <a href="postconf.5.html#local_recipient_maps">local_recipient_maps</a> =
  776. </pre>
  777. </blockquote>
  778. <p> (i.e. empty) in the <a href="postconf.5.html">main.cf</a> file, otherwise the Postfix SMTP
  779. server will reject mail for non-UNIX accounts with "User unknown
  780. in local recipient table". See the <a href="LOCAL_RECIPIENT_README.html">LOCAL_RECIPIENT_README</a> file
  781. for more information on this.
  782. </p>
  783. <p> <a href="postconf.5.html#luser_relay">luser_relay</a> can specify one address. It is subjected to "$name"
  784. expansions. Examples: </p>
  785. <blockquote>
  786. <dl>
  787. <dt>$user@other.host </dt>
  788. <dd> <p> The bare username, without address extension, is prepended
  789. to "@other.host". For example, mail for "username+foo" is sent to
  790. "username@other.host". </p> </dd>
  791. <dt>$local@other.host </dt>
  792. <dd> <p> The entire original recipient localpart, including address
  793. extension, is prepended to "@other.host". For example, mail for
  794. "username+foo" is sent to "username+foo@other.host". </p> </dd>
  795. <dt>sysadmin+$user </dt>
  796. <dd> <p> The bare username, without address extension, is appended
  797. to "sysadmin". For example, mail for "username+foo" is sent to
  798. "sysadmin+username". </p> </dd>
  799. <dt>sysadmin+$local </dt>
  800. <dd> <p> The entire original recipient localpart, including address
  801. extension, is appended to "sysadmin". For example, mail for
  802. "username+foo" is sent to "sysadmin+username+foo". </p> </dd>
  803. </dl>
  804. </blockquote>
  805. <h2> <a name="debugging"> Debugging your address manipulations </a> </h2>
  806. <p> Postfix version 2.1 and later can
  807. produce mail delivery reports for debugging purposes. These reports
  808. not only show sender/recipient addresses after address rewriting
  809. and alias expansion or forwarding, they also show information about
  810. delivery to mailbox, delivery to non-Postfix command, responses
  811. from remote SMTP servers, and so on. </p>
  812. <p> Postfix can produce two types of mail delivery reports for
  813. debugging: </p>
  814. <ul>
  815. <li> <p> What-if: report what would happen, but do not actually
  816. deliver mail. This mode of operation is requested with: </p>
  817. <pre>
  818. $ <b>/usr/sbin/sendmail -bv address...</b>
  819. Mail Delivery Status Report will be mailed to &lt;your login name&gt;.
  820. </pre>
  821. <li> <p> What happened: deliver mail and report successes and/or
  822. failures, including replies from remote SMTP servers. This mode
  823. of operation is requested with: </p>
  824. <pre>
  825. $ <b>/usr/sbin/sendmail -v address...</b>
  826. Mail Delivery Status Report will be mailed to &lt;your login name&gt;.
  827. </pre>
  828. </ul>
  829. <p> These reports contain information that is generated by Postfix
  830. delivery agents. Since these run as daemon processes and do not
  831. interact with users directly, the result is sent as mail to the
  832. sender of the test message. The format of these reports is practically
  833. identical to that of ordinary non-delivery notifications. </p>
  834. <p> As an example, below is the delivery report that is produced
  835. with the command "sendmail -bv postfix-users@postfix.org". The
  836. first part of the report contains human-readable text. In this
  837. case, mail would be delivered via mail.cloud9.net, and the SMTP
  838. server replies with "250 Ok". Other reports may show delivery
  839. to mailbox, or delivery to non-Postfix command. </p>
  840. <blockquote>
  841. <pre>
  842. Content-Description: Notification
  843. Content-Type: text/plain
  844. This is the mail system at host spike.porcupine.org.
  845. Enclosed is the mail delivery report that you requested.
  846. The mail system
  847. &lt;postfix-users@postfix.org&gt;: delivery via mail.cloud9.net[168.100.1.4]: 250 2.1.5 Ok
  848. </pre>
  849. </blockquote>
  850. <p> The second part of the report is in machine-readable form, and
  851. includes the following information: </p>
  852. <ul>
  853. <li> The envelope sender address (wietse@porcupine.org).
  854. <li> The envelope recipient address (postfix-users@postfix.org).
  855. If the recipient address was changed by Postfix then Postfix also
  856. includes the original recipient address.
  857. <li> The delivery status.
  858. </ul>
  859. <p> Some details depend on Postfix version. The example below is
  860. for Postfix version 2.3 and later. </p>
  861. <blockquote>
  862. <pre>
  863. Content-Description: Delivery report
  864. Content-Type: message/delivery-status
  865. Reporting-MTA: dns; spike.porcupine.org
  866. X-Postfix-Queue-ID: 84863BC0E5
  867. X-Postfix-Sender: rfc822; wietse@porcupine.org
  868. Arrival-Date: Sun, 26 Nov 2006 17:01:01 -0500 (EST)
  869. Final-Recipient: rfc822; postfix-users@postfix.org
  870. Action: deliverable
  871. Status: 2.1.5
  872. Remote-MTA: dns; mail.cloud9.net
  873. Diagnostic-Code: smtp; 250 2.1.5 Ok
  874. </pre>
  875. </blockquote>
  876. <p> The third part of the report contains the message that Postfix
  877. would have delivered, including From: and To: message headers, so
  878. that you can see any effects of address rewriting on those. Mail
  879. submitted with "sendmail -bv" has no body content so none is shown
  880. in the example below. </p>
  881. <blockquote>
  882. <pre>
  883. Content-Description: Message
  884. Content-Type: message/rfc822
  885. Received: by spike.porcupine.org (Postfix, from userid 1001)
  886. id 84863BC0E5; Sun, 26 Nov 2006 17:01:01 -0500 (EST)
  887. Subject: probe
  888. To: postfix-users@postfix.org
  889. Message-Id: &lt;20061126220101.84863BC0E5@spike.porcupine.org&gt;
  890. Date: Sun, 26 Nov 2006 17:01:01 -0500 (EST)
  891. From: wietse@porcupine.org (Wietse Venema)
  892. </pre>
  893. </blockquote>
  894. </body>
  895. </html>