xref: /netbsd-src/external/ibm-public/postfix/dist/proto/STANDARD_CONFIGURATION_README.html (revision 059c16a85b0b39d60ad6d18f53c09510815afa2b)
1<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
2        "http://www.w3.org/TR/html4/loose.dtd">
3
4<html>
5
6<head>
7
8<title>Postfix Standard Configuration Examples</title>
9
10<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
11<link rel='stylesheet' type='text/css' href='postfix-doc.css'>
12
13</head>
14
15<body>
16
17<h1><img src="postfix-logo.jpg" width="203" height="98" ALT="">Postfix Standard Configuration Examples</h1>
18
19<hr>
20
21<h2>Purpose of this document</h2>
22
23<p> This document presents a number of typical Postfix configurations.
24This document should be reviewed after you have followed the basic
25configuration steps as described in the BASIC_CONFIGURATION_README
26document. In particular, do not proceed here if you don't already
27have Postfix working for local mail submission and for local mail
28delivery. </p>
29
30<p> The first part of this document presents standard configurations
31that each solve one specific problem. </p>
32
33<ul>
34
35<li><a href="#stand_alone">Postfix on a stand-alone Internet host</a>
36
37<li><a href="#null_client">Postfix on a null client</a>
38
39<li><a href="#local_network">Postfix on a local network</a>
40
41<li><a href="#firewall">Postfix email firewall/gateway</a>
42
43</ul>
44
45<p> The second part of this document presents additional configurations
46for hosts in specific environments. </p>
47
48<ul>
49
50<li><a href="#some_local">Delivering some but not all accounts locally</a>
51
52<li><a href="#intranet">Running Postfix behind a firewall</a>
53
54<li><a href="#backup">Configuring Postfix as primary or backup MX host for a remote
55site</a>
56
57<li><a href="#dialup">Postfix on a dialup machine</a>
58
59<li><a href="#fantasy">Postfix on hosts without a real
60Internet hostname</a>
61
62</ul>
63
64<h2><a name="stand_alone">Postfix on a stand-alone Internet host</a></h2>
65
66<p> Postfix should work out of the box without change on a stand-alone
67machine that has direct Internet access.  At least, that is how
68Postfix installs when you download the Postfix source code via
69http://www.postfix.org/. </p>
70
71<p> You can use the command "<b>postconf -n</b>" to find out what
72settings are overruled by your main.cf. Besides a few pathname
73settings, few parameters should be set on a stand-alone box, beyond
74what is covered in the BASIC_CONFIGURATION_README document: </p>
75
76<blockquote>
77<pre>
78/etc/postfix/main.cf:
79    # Optional: send mail as user@domainname instead of user@hostname.
80    #myorigin = $mydomain
81
82    # Optional: specify NAT/proxy external address.
83    #proxy_interfaces = 1.2.3.4
84
85    # Alternative 1: don't relay mail from other hosts.
86    mynetworks_style = host
87    relay_domains =
88
89    # Alternative 2: relay mail from local clients only.
90    # mynetworks = 192.168.1.0/28
91    # relay_domains =
92</pre>
93</blockquote>
94
95<p> See also the section "<a href="#fantasy">Postfix on hosts without
96a real Internet hostname</a>" if this is applicable to your configuration.
97</p>
98
99<h2><a name="null_client">Postfix on a null client</a></h2>
100
101<p> A null client is a machine that can only send mail. It receives no
102mail from the network, and it does not deliver any mail locally. A
103null client typically uses POP, IMAP or NFS for mailbox access. </p>
104
105<p> In this example we assume that the Internet domain name is
106"example.com" and that the machine is named "hostname.example.com".
107As usual, the examples show only parameters that are not left at
108their default settings. </p>
109
110<blockquote>
111<pre>
1121 /etc/postfix/main.cf:
1132     myhostname = hostname.example.com
1143     myorigin = $mydomain
1154     relayhost = $mydomain
1165     inet_interfaces = loopback-only
1176     mydestination =
118</pre>
119</blockquote>
120
121<p> Translation: </p>
122
123<ul>
124
125<li> <p> Line 2: Set myhostname to hostname.example.com, in case
126the machine name isn't set to a fully-qualified domain name (use
127the command "postconf -d myhostname" to find out what the machine
128name is).  </p>
129
130<li> <p> Line 2: The myhostname value also provides the default
131value for the mydomain parameter (here, "mydomain = example.com").
132</p>
133
134<li> <p> Line 3: Send mail as "user@example.com" (instead of
135"user@hostname.example.com"), so that nothing ever has a reason
136to send mail to "user@hostname.example.com". </p>
137
138<li> <p> Line 4: Forward all mail to the mail server that is
139responsible for the "example.com" domain. This prevents mail from
140getting stuck on the null client if it is turned off while some
141remote destination is unreachable. Specify a real hostname
142here if your "example.com" domain has no MX record. </p>
143
144<li> <p> Line 5: Do not accept mail from the network. </p>
145
146<li> <p> Line 6: Disable local mail delivery. All mail goes to
147the mail server as specified in line 4.  </p>
148
149</ul>
150
151<h2><a name="local_network">Postfix on a local network</a></h2>
152
153<p> This section describes a local area network environment of one
154main server and multiple other systems that send and receive email.
155As usual we assume that the Internet domain name is "example.com".
156All systems are configured to send mail as "user@example.com", and
157all systems receive mail for "user@hostname.example.com".  The main
158server also receives mail for "user@example.com". We call this
159machine by the name of mailhost.example.com. </p>
160
161<p> A drawback of sending mail as "user@example.com" is that mail
162for "root" and other system accounts is also sent to the central
163mailhost. See the section "<a href="#some_local">Delivering some
164but not all accounts locally</a>" below for possible solutions.
165</p>
166
167<p> As usual, the examples show only parameters that are not left
168at their default settings. </p>
169
170<p> First we present the non-mailhost configuration, because it is
171the simpler one. This machine sends mail as "user@example.com" and
172is the final destination for "user@hostname.example.com". </p>
173
174<blockquote>
175<pre>
1761 /etc/postfix/main.cf:
1772     myorigin = $mydomain
1783     mynetworks = 127.0.0.0/8 10.0.0.0/24
1794     relay_domains =
1805     # Optional: forward all non-local mail to mailhost
1816     #relayhost = $mydomain
182</pre>
183</blockquote>
184
185<p> Translation: </p>
186
187<ul>
188
189<li> <p> Line 2: Send mail as "user@example.com". </p>
190
191<li> <p> Line 3: Specify the trusted networks. </p>
192
193<li> <p> Line 4: This host does not relay mail from untrusted networks. </p>
194
195<li> <p> Line 6: This is needed if no direct Internet access is
196available.  See also below, "<a href="#firewall">Postfix behind
197a firewall</a>". </p>
198
199</ul>
200
201<p> Next we present the mailhost configuration.  This machine sends
202mail as "user@example.com" and is the final destination for
203"user@hostname.example.com" as well as "user@example.com". </p>
204
205<blockquote>
206<pre>
207 1 DNS:
208 2     example.com    IN    MX  10 mailhost.example.com.
209 3
210 4 /etc/postfix/main.cf:
211 5     myorigin = $mydomain
212 6     mydestination = $myhostname localhost.$mydomain localhost $mydomain
213 7     mynetworks = 127.0.0.0/8 10.0.0.0/24
214 8     relay_domains =
215 9     # Optional: forward all non-local mail to firewall
21610     #relayhost = [firewall.example.com]
217</pre>
218</blockquote>
219
220<p> Translation: </p>
221
222<ul>
223
224<li> <p> Line 2: Send mail for the domain "example.com" to the
225machine mailhost.example.com.  Remember to specify the "." at the
226end of the line. </p>
227
228<li> <p> Line 5: Send mail as "user@example.com". </p>
229
230<li> <p> Line 6: This host is the final mail destination for the
231"example.com" domain, in addition to the names of the machine
232itself. </p>
233
234<li> <p> Line 7: Specify the trusted networks. </p>
235
236<li> <p> Line 8: This host does not relay mail from untrusted networks. </p>
237
238<li> <p> Line 10: This is needed only when the mailhost has to
239forward non-local mail via a mail server on a firewall.  The
240<tt>[]</tt> forces Postfix to do no MX record lookups. </p>
241
242</ul>
243
244<p> In an environment like this, users access their mailbox in one
245or more of the following ways:
246
247<ul>
248
249<li> <p> Mailbox access via NFS or equivalent.  </p>
250
251<li> <p> Mailbox access via POP or IMAP. </p>
252
253<li> <p> Mailbox on the user's preferred machine. </p>
254
255</ul>
256
257<p> In the latter case, each user has an alias on the mailhost that
258forwards mail to her preferred machine: </p>
259
260<blockquote>
261<pre>
262/etc/aliases:
263    joe:    joe@joes.preferred.machine
264    jane:   jane@janes.preferred.machine
265</pre>
266</blockquote>
267
268<p> On some systems the alias database is not in /etc/aliases.  To
269find out the location for your system, execute the command "<b>postconf
270alias_maps</b>". </p>
271
272<p> Execute the command "<b>newaliases</b>" whenever you change
273the aliases file.  </p>
274
275<h2><a name="firewall">Postfix email firewall/gateway</a></h2>
276
277<p> The idea is to set up a Postfix email firewall/gateway that
278forwards mail for "example.com" to an inside gateway machine but
279rejects mail for "anything.example.com". There is only one problem:
280with "relay_domains = example.com", the firewall normally also
281accepts mail for "anything.example.com".  That would not be right.
282</p>
283
284<p> Note: this example requires Postfix version 2.0 and later. To find
285out what Postfix version you have, execute the command "<b>postconf
286mail_version</b>". </p>
287
288<p> The solution is presented in multiple parts. This first part
289gets rid of local mail delivery on the firewall, making the firewall
290harder to break. </p>
291
292<blockquote>
293<pre>
2941 /etc/postfix/main.cf:
2952     myorigin = example.com
2963     mydestination =
2974     local_recipient_maps =
2985     local_transport = error:local mail delivery is disabled
2996
3007 /etc/postfix/master.cf:
3018     Comment out the local delivery agent
302</pre>
303</blockquote>
304
305<p> Translation: </p>
306
307<ul>
308
309<li> <p> Line 2: Send mail from this machine as "user@example.com",
310so that no reason exists to send mail to "user@firewall.example.com".
311</p>
312
313<li> <p> Lines 3-8: Disable local mail delivery on the firewall
314machine. </p>
315
316</ul>
317
318<p> For the sake of technical correctness the firewall must be able
319to receive mail for postmaster@[firewall ip address]. Reportedly,
320some things actually expect this ability to exist. The second part
321of the solution therefore adds support for postmaster@[firewall ip
322address], and as a bonus we do abuse@[firewall ip address] as well.
323All the mail to these two accounts is forwarded to an inside address.
324</p>
325
326<blockquote>
327<pre>
3281 /etc/postfix/main.cf:
3292     virtual_alias_maps = hash:/etc/postfix/virtual
3303
3314 /etc/postfix/virtual:
3325     postmaster      postmaster@example.com
3336     abuse           abuse@example.com
334</pre>
335</blockquote>
336
337<p> Translation: </p>
338
339<ul>
340
341<li> <p> Because mydestination is empty (see the previous example),
342only address literals matching $inet_interfaces or $proxy_interfaces
343are deemed local.  So "localpart@[a.d.d.r]" can be matched as simply
344"localpart" in canonical(5) and virtual(5). This avoids the need to
345specify firewall IP addresses in Postfix configuration files. </p>
346
347</ul>
348
349<p> The last part of the solution does the email forwarding, which
350is the real purpose of the firewall email function. </p>
351
352<blockquote>
353<pre>
354 1 /etc/postfix/main.cf:
355 2     mynetworks = 127.0.0.0/8 12.34.56.0/24
356 3     relay_domains = example.com
357 4     parent_domain_matches_subdomains =
358 5         debug_peer_list smtpd_access_maps
359<br>
360 6a    # Postfix 2.10 and later support separate relay control and
361 7a    # spam control.
362 8a    smtpd_relay_restrictions =
363 9a        permit_mynetworks reject_unauth_destination
36410a    smtpd_recipient_restrictions = ...spam blocking rules....
365<br>
366 6b    # Older configurations combine relay control and spam control. To
367 7b    # use this with Postfix &ge; 2.10 specify "smtpd_relay_restrictions=".
368 8b    smtpd_recipient_restrictions =
369 9b        permit_mynetworks reject_unauth_destination
37010b        ...spam blocking rules....
371<br>
37211     relay_recipient_maps = hash:/etc/postfix/relay_recipients
37312     transport_maps = hash:/etc/postfix/transport
37413
37514 /etc/postfix/relay_recipients:
37615     user1@example.com   x
37716     user2@example.com   x
37817      . . .
37918
38019 /etc/postfix/transport:
38120     example.com   relay:[inside-gateway.example.com]
382</pre>
383</blockquote>
384
385<p> Translation: </p>
386
387<ul>
388
389<li><p> Lines 1-10: Accept mail from local systems in $mynetworks,
390and accept mail from outside for "user@example.com" but not for
391"user@anything.example.com". The magic is in lines 4-5. </p>
392
393<li> <p> Lines 11, 13-16: Define the list of valid addresses in the
394"example.com" domain that can receive mail from the Internet. This
395prevents the mail queue from filling up with undeliverable
396MAILER-DAEMON messages. If you can't maintain a list of valid
397recipients then you must specify "relay_recipient_maps =" (that
398is, an empty value), or you must specify an "@example.com  x"
399wild-card in the relay_recipients table. </p>
400
401<li> <p> Lines 12, 19-20: Route mail for "example.com" to the inside
402gateway machine. The <tt>[]</tt> forces Postfix to do no MX lookup.
403This uses the "relay" delivery transport (a copy of the default
404"smtp" delivery transport) to forward inbound mail. This can improve
405performance of deliveries to internal domains because they will
406compete for SMTP clients from the "relay" delivery transport, instead
407of competing with other SMTP deliveries for SMTP clients from the
408default "smtp" delivery transport. </p>
409
410</ul>
411
412<p>Specify <b>dbm</b> instead of <b>hash</b> if your system uses
413<b>dbm</b> files instead of <b>db</b> files. To find out what lookup
414tables Postfix supports, use the command "<b>postconf -m</b>".  </p>
415
416<p> Execute the command "<b>postmap /etc/postfix/relay_recipients</b>"
417whenever you change the relay_recipients table. </p>
418
419<p> Execute the command "<b>postmap /etc/postfix/transport</b>"
420whenever you change the transport table. </p>
421
422<p> In some installations, there may be separate instances of Postfix
423processing inbound and outbound mail on a multi-homed firewall. The
424inbound Postfix instance has an SMTP server listening on the external
425firewall interface, and the outbound Postfix instance has an SMTP server
426listening on the internal interface. In such a configuration is it is
427tempting to configure $inet_interfaces in each instance with just the
428corresponding interface address. </p>
429
430<p> In most cases, using inet_interfaces in this way will not work,
431because as documented in the $inet_interfaces reference manual, the
432smtp(8) delivery agent will also use the specified interface address
433as the source address for outbound connections and will be unable to
434reach hosts on "the other side" of the firewall. The symptoms are that
435the firewall is unable to connect to hosts that are in fact up. See the
436inet_interfaces parameter documentation for suggested work-arounds.</p>
437
438<h2><a name="some_local">Delivering some but not all accounts
439locally</a></h2>
440
441<p> A drawback of sending mail as "user@example.com" (instead of
442"user@hostname.example.com") is that mail for "root" and other
443system accounts is also sent to the central mailhost.  In order to
444deliver such accounts locally, you can set up virtual aliases as
445follows:  </p>
446
447<blockquote>
448<pre>
4491 /etc/postfix/main.cf:
4502     virtual_alias_maps = hash:/etc/postfix/virtual
4513
4524 /etc/postfix/virtual:
4535     root     root@localhost
4546     . . .
455</pre>
456</blockquote>
457
458<p> Translation: </p>
459
460<ul>
461
462<li> <p> Line 5: As described in the virtual(5) manual page, the
463bare name "root" matches "root@site" when "site" is equal to
464$myorigin, when "site" is listed in $mydestination, or when it
465matches $inet_interfaces or $proxy_interfaces. </p>
466
467</ul>
468
469<p> Execute the command "<b>postmap /etc/postfix/virtual</b>" after
470editing the file. </p>
471
472<h2><a name="intranet">Running Postfix behind a firewall</a></h2>
473
474<p> The simplest way to set up Postfix on a host behind a firewalled
475network is to send all mail to a gateway host, and to let that mail
476host take care of internal and external forwarding. Examples of that
477are shown in the <a href="#local_network">local area network</a>
478section above. A more sophisticated approach is to send only external
479mail to the gateway host, and to send intranet mail directly. </p>
480
481<p> Note: this example requires Postfix version 2.0 and later. To find
482out what Postfix version you have, execute the command "<b>postconf
483mail_version</b>". </p>
484
485<p> The following example presents additional configuration. You
486need to combine this with basic configuration information as
487discussed in the first half of this document. </p>
488
489<blockquote>
490<pre>
491 1 /etc/postfix/main.cf:
492 2     transport_maps = hash:/etc/postfix/transport
493 3     relayhost =
494 4     # Optional for a machine that isn't "always on"
495 5     #fallback_relay = [gateway.example.com]
496 6
497 7 /etc/postfix/transport:
498 8     # Internal delivery.
499 9     example.com      :
50010     .example.com     :
50111     # External delivery.
50212     *                smtp:[gateway.example.com]
503</pre>
504</blockquote>
505
506<p> Translation: </p>
507
508<ul>
509
510<li> <p> Lines 2, 7-12: Request that intranet mail is delivered
511directly, and that external mail is given to a gateway. Obviously,
512this example assumes that the organization uses DNS MX records
513internally.  The <tt>[]</tt> forces Postfix to do no MX lookup.
514</p>
515
516<li> <p> Line 3: IMPORTANT: do not specify a relayhost in main.cf.
517</p>
518
519<li> <p> Line 5: This prevents mail from being stuck in the queue
520when the machine is turned off.  Postfix tries to deliver mail
521directly, and gives undeliverable mail to a gateway.  </p>
522
523</ul>
524
525<p> Specify <b>dbm</b> instead of <b>hash</b> if your system uses
526<b>dbm</b> files instead of <b>db</b> files. To find out what lookup
527tables Postfix supports, use the command "<b>postconf -m</b>". </p>
528
529<p> Execute the command "<b>postmap /etc/postfix/transport</b>" whenever
530you edit the transport table. </p>
531
532<h2><a name="backup">Configuring Postfix as primary or backup MX host for a remote site</a></h2>
533
534<p> This section presents additional configuration. You need to
535combine this with basic configuration information as discussed in the
536first half of this document. </p>
537
538<p> When your system is SECONDARY MX host for a remote site this
539is all you need: </p>
540
541<blockquote>
542<pre>
543 1 DNS:
544 2     the.backed-up.domain.tld        IN      MX 100 your.machine.tld.
545 3
546 4 /etc/postfix/main.cf:
547 5     relay_domains = . . . the.backed-up.domain.tld
548<br>
549 6a    # Postfix 2.10 and later support separate relay control and
550 7a    # spam control.
551 8a    smtpd_relay_restrictions =
552 9a        permit_mynetworks reject_unauth_destination
55310a    smtpd_recipient_restrictions = ...spam blocking rules....
554<br>
555 6b    # Older configurations combine relay control and spam control. To
556 7b    # use this with Postfix &ge; 2.10 specify "smtpd_relay_restrictions=".
557 8b    smtpd_recipient_restrictions =
558 9b        permit_mynetworks reject_unauth_destination
55910b        ...spam blocking rules....
560<br>
56111     # You must specify your NAT/proxy external address.
56212     #proxy_interfaces = 1.2.3.4
56313
56414     relay_recipient_maps = hash:/etc/postfix/relay_recipients
56515
56616 /etc/postfix/relay_recipients:
56717     user1@the.backed-up.domain.tld   x
56818     user2@the.backed-up.domain.tld   x
56919      . . .
570</pre>
571</blockquote>
572
573<p> When your system is PRIMARY MX host for a remote site you
574need the above, plus: </p>
575
576<blockquote>
577<pre>
57820 /etc/postfix/main.cf:
57921     transport_maps = hash:/etc/postfix/transport
58022
58123 /etc/postfix/transport:
58224     the.backed-up.domain.tld       relay:[their.mail.host.tld]
583</pre>
584</blockquote>
585
586<p> Important notes:
587
588<ul>
589
590<li><p>Do not list the.backed-up.domain.tld in mydestination.</p>
591
592<li><p>Do not list the.backed-up.domain.tld in virtual_alias_domains.</p>
593
594<li><p>Do not list the.backed-up.domain.tld in virtual_mailbox_domains.</p>
595
596<li> <p> Lines 1-9: Forward mail from the Internet for
597"the.backed-up.domain.tld" to the primary MX host for that domain.
598</p>
599
600<li> <p> Line 12: This is a must if Postfix receives mail via a
601NAT relay or proxy that presents a different IP address to the
602world than the local machine. </p>
603
604<li> <p> Lines 14-18: Define the list of valid addresses in the
605"the.backed-up.domain.tld" domain.  This prevents your mail queue
606from filling up with undeliverable MAILER-DAEMON messages. If you
607can't maintain a list of valid recipients then you must specify
608"relay_recipient_maps =" (that is, an empty value), or you must
609specify an "@the.backed-up.domain.tld  x" wild-card in the
610relay_recipients table. </p>
611
612<li> <p> Line 24: The <tt>[]</tt> forces Postfix to do no MX lookup. </p>
613
614</ul>
615
616<p> Specify <b>dbm</b> instead of <b>hash</b> if your system uses
617<b>dbm</b> files instead of <b>db</b> files. To find out what lookup
618tables Postfix supports, use the command "<b>postconf -m</b>". </p>
619
620<p> Execute the command "<b>postmap /etc/postfix/transport</b>"
621whenever you change the transport table. </p>
622
623<p> NOTE for Postfix &lt; 2.2: Do not use the fallback_relay feature
624when relaying mail
625for a backup or primary MX domain. Mail would loop between the
626Postfix MX host and the fallback_relay host when the final destination
627is unavailable. </p>
628
629<ul>
630
631<li> In main.cf specify "<tt>relay_transport = relay</tt>",
632
633<li> In master.cf specify "<tt>-o fallback_relay =</tt>" at the
634end of the <tt>relay</tt> entry.
635
636<li> In transport maps, specify "<tt>relay:<i>nexthop...</i></tt>"
637as the right-hand side for backup or primary MX domain entries.
638
639</ul>
640
641<p> These are default settings in Postfix version 2.2 and later.
642</p>
643
644<h2><a name="dialup">Postfix on a dialup machine</a></h2>
645
646<p> This section applies to dialup connections that are down most
647of the time. For dialup connections that are up 24x7, see the <a
648href="#local_network">local area network</a> section above.  </p>
649
650<p> This section presents additional configuration. You need to
651combine this with basic configuration information as discussed in the
652first half of this document. </p>
653
654<p> If you do not have your own hostname and IP address (usually
655with dialup, cable TV or DSL connections) then you should also
656study the section on "<a href="#fantasy">Postfix on hosts without
657a real Internet hostname</a>".  </p>
658
659<ul>
660
661<li> Route all outgoing mail to your network provider.
662
663<p> If your machine is disconnected most of the time, there isn't
664a lot of opportunity for Postfix to deliver mail to hard-to-reach
665corners of the Internet. It's better to give the mail to a machine
666that is connected all the time. In the example below, the <tt>[]</tt>
667prevents Postfix from trying to look up DNS MX records.  </p>
668
669<pre>
670/etc/postfix/main.cf:
671    relayhost = [smtprelay.someprovider.com]
672</pre>
673
674<li> <p><a name="spontaneous_smtp">Disable spontaneous SMTP mail
675delivery (if using on-demand dialup IP only).</a> </p>
676
677<p> Normally, Postfix attempts to deliver outbound mail at its convenience.
678If your machine uses on-demand dialup IP, this causes your system
679to place a telephone call whenever you submit new mail, and whenever
680Postfix retries to deliver delayed mail. To prevent such telephone
681calls from being placed, disable spontaneous SMTP mail deliveries. </p>
682
683<pre>
684/etc/postfix/main.cf:
685    defer_transports = smtp (Only for on-demand dialup IP hosts)
686</pre>
687
688<li> <p>Disable SMTP client DNS lookups (dialup LAN only).</p>
689
690<pre>
691/etc/postfix/main.cf:
692    disable_dns_lookups = yes (Only for on-demand dialup IP hosts)
693</pre>
694
695<li> Flush the mail queue whenever the Internet link is established.
696
697<p> Put the following command into your PPP or SLIP dialup scripts: </p>
698
699<pre>
700/usr/sbin/sendmail -q (whenever the Internet link is up)
701</pre>
702
703<p> The exact location of the Postfix sendmail command is system-specific.
704Use the command "<b>postconf sendmail_path</b>" to find out where the
705Postfix sendmail command is located on your machine. </p>
706
707<p> In order to find out if the mail queue is flushed, use something
708like: </p>
709
710<pre>
711#!/bin/sh
712
713# Start mail deliveries.
714/usr/sbin/sendmail -q
715
716# Allow deliveries to start.
717sleep 10
718
719# Loop until all messages have been tried at least once.
720while mailq | grep '^[^ ]*\*' &gt;/dev/null
721do
722    sleep 10
723done
724</pre>
725
726<p> If you have disabled <a href="#spontaneous_smtp">spontaneous
727SMTP mail delivery</a>, you also need to run the "<b>sendmail -q</b>"
728command every now and then while the dialup link is up, so that
729newly-posted mail is flushed from the queue. </p>
730
731</ul>
732
733<h2><a name="fantasy">Postfix on hosts without a real Internet
734hostname</a></h2>
735
736<p> This section is for hosts that don't have their own Internet
737hostname.  Typically these are systems that get a dynamic IP address
738via DHCP or via dialup. Postfix will let you send and receive mail
739just fine between accounts on a machine with a fantasy name. However,
740you cannot use a fantasy hostname in your email address when sending
741mail into the Internet, because no-one would be able to reply to
742your mail. In fact, more and more sites refuse mail addresses with
743non-existent domain names. </p>
744
745<p> Note: the following information is Postfix version dependent.
746To find out what Postfix version you have, execute the command
747"<b>postconf mail_version</b>". </p>
748
749<h3>Solution 1: Postfix version 2.2 and later </h3>
750
751<p> Postfix 2.2 uses the generic(5) address mapping to replace
752local fantasy email addresses by valid Internet addresses.  This
753mapping happens ONLY when mail leaves the machine; not when you
754send mail between users on the same machine. </p>
755
756<p> The following example presents additional configuration. You
757need to combine this with basic configuration information as
758discussed in the first half of this document. </p>
759
760<blockquote>
761<pre>
7621 /etc/postfix/main.cf:
7632     smtp_generic_maps = hash:/etc/postfix/generic
7643
7654 /etc/postfix/generic:
7665     his@localdomain.local             hisaccount@hisisp.example
7676     her@localdomain.local             heraccount@herisp.example
7687     @localdomain.local                hisaccount+local@hisisp.example
769</pre>
770</blockquote>
771
772<p> When mail is sent to a remote host via SMTP: </p>
773
774<ul>
775
776<li> <p> Line 5 replaces <i>his@localdomain.local</i> by his ISP
777mail address, </p>
778
779<li> <p> Line 6 replaces <i>her@localdomain.local</i> by her ISP
780mail address, and </p>
781
782<li> <p> Line 7 replaces other local addresses by his ISP account,
783with an address extension of +<i>local</i> (this example assumes
784that the ISP supports "+" style address extensions). </p>
785
786</ul>
787
788<p>Specify <b>dbm</b> instead of <b>hash</b> if your system uses
789<b>dbm</b> files instead of <b>db</b> files. To find out what lookup
790tables Postfix supports, use the command "<b>postconf -m</b>".  </p>
791
792<p> Execute the command "<b>postmap /etc/postfix/generic</b>"
793whenever you change the generic table. </p>
794
795<h3>Solution 2: Postfix version 2.1 and earlier </h3>
796
797<p> The solution with older Postfix systems is to use valid
798Internet addresses where possible, and to let Postfix map valid
799Internet addresses to local fantasy addresses. With this, you can
800send mail to the Internet and to local fantasy addresses, including
801mail to local fantasy addresses that don't have a valid Internet
802address of their own.</p>
803
804<p> The following example presents additional configuration. You
805need to combine this with basic configuration information as
806discussed in the first half of this document. </p>
807
808<blockquote>
809<pre>
810 1 /etc/postfix/main.cf:
811 2     myhostname = hostname.localdomain
812 3     mydomain = localdomain
813 4
814 5     canonical_maps = hash:/etc/postfix/canonical
815 6
816 7     virtual_alias_maps = hash:/etc/postfix/virtual
817 8
818 9 /etc/postfix/canonical:
81910     your-login-name    your-account@your-isp.com
82011
82112 /etc/postfix/virtual:
82213     your-account@your-isp.com       your-login-name
823</pre>
824</blockquote>
825
826<p> Translation: </p>
827
828<ul>
829
830<li> <p> Lines 2-3: Substitute your fantasy hostname here. Do not
831use a domain name that is already in use by real organizations
832on the Internet. See RFC 2606 for examples of domain
833names that are guaranteed not to be owned by anyone. </p>
834
835<li> <p> Lines 5, 9, 10: This provides the mapping from
836"your-login-name@hostname.localdomain" to "your-account@your-isp.com".
837This part is required. </p>
838
839<li> <p> Lines 7, 12, 13: Deliver mail for "your-account@your-isp.com"
840locally, instead of sending it to the ISP. This part is not required
841but is convenient.
842
843</ul>
844
845<p>Specify <b>dbm</b> instead of <b>hash</b> if your system uses
846<b>dbm</b> files instead of <b>db</b> files. To find out what lookup
847tables Postfix supports, use the command "<b>postconf -m</b>".  </p>
848
849<p> Execute the command "<b>postmap /etc/postfix/canonical</b>"
850whenever you change the canonical table. </p>
851
852<p> Execute the command "<b>postmap /etc/postfix/virtual</b>"
853whenever you change the virtual table. </p>
854
855</body>
856
857</html>
858