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