STANDARD_CONFIGURATION_README.html revision 1.1.1.6 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.
24 This document should be reviewed after you have followed the basic
25 configuration steps as described in the BASIC_CONFIGURATION_README
26 document. In particular, do not proceed here if you don't already
27 have Postfix working for local mail submission and for local mail
28 delivery. </p>
29
30 <p> The first part of this document presents standard configurations
31 that 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
46 for 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
55 site</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
60 Internet 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
67 machine that has direct Internet access. At least, that is how
68 Postfix installs when you download the Postfix source code via
69 http://www.postfix.org/. </p>
70
71 <p> You can use the command "<b>postconf -n</b>" to find out what
72 settings are overruled by your main.cf. Besides a few pathname
73 settings, few parameters should be set on a stand-alone box, beyond
74 what 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
96 a 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
102 mail from the network, and it does not deliver any mail locally. A
103 null 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".
107 As usual, the examples show only parameters that are not left at
108 their default settings. </p>
109
110 <blockquote>
111 <pre>
112 1 /etc/postfix/main.cf:
113 2 myhostname = hostname.example.com
114 3 myorigin = $mydomain
115 4 relayhost = $mydomain
116 5 inet_interfaces = loopback-only
117 6 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
126 the machine name isn't set to a fully-qualified domain name (use
127 the command "postconf -d myhostname" to find out what the machine
128 name is). </p>
129
130 <li> <p> Line 2: The myhostname value also provides the default
131 value for the mydomain parameter (here, "mydomain = example.com").
132 </p>
133
134 <li> <p> Line 3: Send mail as "user (a] example.com" (instead of
135 "user (a] hostname.example.com"), so that nothing ever has a reason
136 to send mail to "user (a] hostname.example.com". </p>
137
138 <li> <p> Line 4: Forward all mail to the mail server that is
139 responsible for the "example.com" domain. This prevents mail from
140 getting stuck on the null client if it is turned off while some
141 remote destination is unreachable. Specify a real hostname
142 here 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
147 the 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
154 main server and multiple other systems that send and receive email.
155 As usual we assume that the Internet domain name is "example.com".
156 All systems are configured to send mail as "user (a] example.com", and
157 all systems receive mail for "user (a] hostname.example.com". The main
158 server also receives mail for "user (a] example.com". We call this
159 machine by the name of mailhost.example.com. </p>
160
161 <p> A drawback of sending mail as "user (a] example.com" is that mail
162 for "root" and other system accounts is also sent to the central
163 mailhost. See the section "<a href="#some_local">Delivering some
164 but 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
168 at their default settings. </p>
169
170 <p> First we present the non-mailhost configuration, because it is
171 the simpler one. This machine sends mail as "user (a] example.com" and
172 is the final destination for "user (a] hostname.example.com". </p>
173
174 <blockquote>
175 <pre>
176 1 /etc/postfix/main.cf:
177 2 myorigin = $mydomain
178 3 mynetworks = 127.0.0.0/8 10.0.0.0/24
179 4 relay_domains =
180 5 # Optional: forward all non-local mail to mailhost
181 6 #relayhost = $mydomain
182 </pre>
183 </blockquote>
184
185 <p> Translation: </p>
186
187 <ul>
188
189 <li> <p> Line 2: Send mail as "user (a] 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
196 available. See also below, "<a href="#firewall">Postfix behind
197 a firewall</a>". </p>
198
199 </ul>
200
201 <p> Next we present the mailhost configuration. This machine sends
202 mail as "user (a] example.com" and is the final destination for
203 "user (a] hostname.example.com" as well as "user (a] 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
216 10 #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
225 machine mailhost.example.com. Remember to specify the "." at the
226 end of the line. </p>
227
228 <li> <p> Line 5: Send mail as "user (a] 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
232 itself. </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
239 forward 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
245 or 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
258 forwards mail to her preferred machine: </p>
259
260 <blockquote>
261 <pre>
262 /etc/aliases:
263 joe: joe (a] joes.preferred.machine
264 jane: jane (a] janes.preferred.machine
265 </pre>
266 </blockquote>
267
268 <p> On some systems the alias database is not in /etc/aliases. To
269 find out the location for your system, execute the command "<b>postconf
270 alias_maps</b>". </p>
271
272 <p> Execute the command "<b>newaliases</b>" whenever you change
273 the 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
278 forwards mail for "example.com" to an inside gateway machine but
279 rejects mail for "anything.example.com". There is only one problem:
280 with "relay_domains = example.com", the firewall normally also
281 accepts 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
285 out what Postfix version you have, execute the command "<b>postconf
286 mail_version</b>". </p>
287
288 <p> The solution is presented in multiple parts. This first part
289 gets rid of local mail delivery on the firewall, making the firewall
290 harder to break. </p>
291
292 <blockquote>
293 <pre>
294 1 /etc/postfix/main.cf:
295 2 myorigin = example.com
296 3 mydestination =
297 4 local_recipient_maps =
298 5 local_transport = error:local mail delivery is disabled
299 6
300 7 /etc/postfix/master.cf:
301 8 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 (a] example.com",
310 so that no reason exists to send mail to "user (a] firewall.example.com".
311 </p>
312
313 <li> <p> Lines 3-8: Disable local mail delivery on the firewall
314 machine. </p>
315
316 </ul>
317
318 <p> For the sake of technical correctness the firewall must be able
319 to receive mail for postmaster@[firewall ip address]. Reportedly,
320 some things actually expect this ability to exist. The second part
321 of the solution therefore adds support for postmaster@[firewall ip
322 address], and as a bonus we do abuse@[firewall ip address] as well.
323 All the mail to these two accounts is forwarded to an inside address.
324 </p>
325
326 <blockquote>
327 <pre>
328 1 /etc/postfix/main.cf:
329 2 virtual_alias_maps = hash:/etc/postfix/virtual
330 3
331 4 /etc/postfix/virtual:
332 5 postmaster postmaster (a] example.com
333 6 abuse abuse (a] 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),
342 only address literals matching $inet_interfaces or $proxy_interfaces
343 are 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
345 specify 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
350 is 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
364 10a 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 ≥ 2.10 specify "smtpd_relay_restrictions=".
368 8b smtpd_recipient_restrictions =
369 9b permit_mynetworks reject_unauth_destination
370 10b ...spam blocking rules....
371 <br>
372 11 relay_recipient_maps = hash:/etc/postfix/relay_recipients
373 12 transport_maps = hash:/etc/postfix/transport
374 13
375 14 /etc/postfix/relay_recipients:
376 15 user1 (a] example.com x
377 16 user2 (a] example.com x
378 17 . . .
379 18
380 19 /etc/postfix/transport:
381 20 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,
390 and accept mail from outside for "user (a] example.com" but not for
391 "user (a] 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
395 prevents the mail queue from filling up with undeliverable
396 MAILER-DAEMON messages. If you can't maintain a list of valid
397 recipients then you must specify "relay_recipient_maps =" (that
398 is, an empty value), or you must specify an "@example.com x"
399 wild-card in the relay_recipients table. </p>
400
401 <li> <p> Lines 12, 19-20: Route mail for "example.com" to the inside
402 gateway machine. The <tt>[]</tt> forces Postfix to do no MX lookup.
403 This uses the "relay" delivery transport (a copy of the default
404 "smtp" delivery transport) to forward inbound mail. This can improve
405 performance of deliveries to internal domains because they will
406 compete for SMTP clients from the "relay" delivery transport, instead
407 of competing with other SMTP deliveries for SMTP clients from the
408 default "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
414 tables Postfix supports, use the command "<b>postconf -m</b>". </p>
415
416 <p> Execute the command "<b>postmap /etc/postfix/relay_recipients</b>"
417 whenever you change the relay_recipients table. </p>
418
419 <p> Execute the command "<b>postmap /etc/postfix/transport</b>"
420 whenever you change the transport table. </p>
421
422 <p> In some installations, there may be separate instances of Postfix
423 processing inbound and outbound mail on a multi-homed firewall. The
424 inbound Postfix instance has an SMTP server listening on the external
425 firewall interface, and the outbound Postfix instance has an SMTP server
426 listening on the internal interface. In such a configuration is it is
427 tempting to configure $inet_interfaces in each instance with just the
428 corresponding interface address. </p>
429
430 <p> In most cases, using inet_interfaces in this way will not work,
431 because as documented in the $inet_interfaces reference manual, the
432 smtp(8) delivery agent will also use the specified interface address
433 as the source address for outbound connections and will be unable to
434 reach hosts on "the other side" of the firewall. The symptoms are that
435 the firewall is unable to connect to hosts that are in fact up. See the
436 inet_interfaces parameter documentation for suggested work-arounds.</p>
437
438 <h2><a name="some_local">Delivering some but not all accounts
439 locally</a></h2>
440
441 <p> A drawback of sending mail as "user (a] example.com" (instead of
442 "user (a] hostname.example.com") is that mail for "root" and other
443 system accounts is also sent to the central mailhost. In order to
444 deliver such accounts locally, you can set up virtual aliases as
445 follows: </p>
446
447 <blockquote>
448 <pre>
449 1 /etc/postfix/main.cf:
450 2 virtual_alias_maps = hash:/etc/postfix/virtual
451 3
452 4 /etc/postfix/virtual:
453 5 root root@localhost
454 6 . . .
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
463 bare name "root" matches "root@site" when "site" is equal to
464 $myorigin, when "site" is listed in $mydestination, or when it
465 matches $inet_interfaces or $proxy_interfaces. </p>
466
467 </ul>
468
469 <p> Execute the command "<b>postmap /etc/postfix/virtual</b>" after
470 editing 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
475 network is to send all mail to a gateway host, and to let that mail
476 host take care of internal and external forwarding. Examples of that
477 are shown in the <a href="#local_network">local area network</a>
478 section above. A more sophisticated approach is to send only external
479 mail 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
482 out what Postfix version you have, execute the command "<b>postconf
483 mail_version</b>". </p>
484
485 <p> The following example presents additional configuration. You
486 need to combine this with basic configuration information as
487 discussed 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 :
500 10 .example.com :
501 11 # External delivery.
502 12 * 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
511 directly, and that external mail is given to a gateway. Obviously,
512 this example assumes that the organization uses DNS MX records
513 internally. 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
520 when the machine is turned off. Postfix tries to deliver mail
521 directly, 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
527 tables Postfix supports, use the command "<b>postconf -m</b>". </p>
528
529 <p> Execute the command "<b>postmap /etc/postfix/transport</b>" whenever
530 you 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
535 combine this with basic configuration information as discussed in the
536 first half of this document. </p>
537
538 <p> When your system is SECONDARY MX host for a remote site this
539 is 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
553 10a 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 ≥ 2.10 specify "smtpd_relay_restrictions=".
557 8b smtpd_recipient_restrictions =
558 9b permit_mynetworks reject_unauth_destination
559 10b ...spam blocking rules....
560 <br>
561 11 # You must specify your NAT/proxy external address.
562 12 #proxy_interfaces = 1.2.3.4
563 13
564 14 relay_recipient_maps = hash:/etc/postfix/relay_recipients
565 15
566 16 /etc/postfix/relay_recipients:
567 17 user1 (a] the.backed-up.domain.tld x
568 18 user2 (a] the.backed-up.domain.tld x
569 19 . . .
570 </pre>
571 </blockquote>
572
573 <p> When your system is PRIMARY MX host for a remote site you
574 need the above, plus: </p>
575
576 <blockquote>
577 <pre>
578 20 /etc/postfix/main.cf:
579 21 transport_maps = hash:/etc/postfix/transport
580 22
581 23 /etc/postfix/transport:
582 24 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
601 NAT relay or proxy that presents a different IP address to the
602 world 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
606 from filling up with undeliverable MAILER-DAEMON messages. If you
607 can't maintain a list of valid recipients then you must specify
608 "relay_recipient_maps =" (that is, an empty value), or you must
609 specify an "@the.backed-up.domain.tld x" wild-card in the
610 relay_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
618 tables Postfix supports, use the command "<b>postconf -m</b>". </p>
619
620 <p> Execute the command "<b>postmap /etc/postfix/transport</b>"
621 whenever you change the transport table. </p>
622
623 <p> NOTE for Postfix < 2.2: Do not use the fallback_relay feature
624 when relaying mail
625 for a backup or primary MX domain. Mail would loop between the
626 Postfix MX host and the fallback_relay host when the final destination
627 is 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
634 end of the <tt>relay</tt> entry.
635
636 <li> In transport maps, specify "<tt>relay:<i>nexthop...</i></tt>"
637 as 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
647 of the time. For dialup connections that are up 24x7, see the <a
648 href="#local_network">local area network</a> section above. </p>
649
650 <p> This section presents additional configuration. You need to
651 combine this with basic configuration information as discussed in the
652 first half of this document. </p>
653
654 <p> If you do not have your own hostname and IP address (usually
655 with dialup, cable TV or DSL connections) then you should also
656 study the section on "<a href="#fantasy">Postfix on hosts without
657 a 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
664 a lot of opportunity for Postfix to deliver mail to hard-to-reach
665 corners of the Internet. It's better to give the mail to a machine
666 that is connected all the time. In the example below, the <tt>[]</tt>
667 prevents 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
675 delivery (if using on-demand dialup IP only).</a> </p>
676
677 <p> Normally, Postfix attempts to deliver outbound mail at its convenience.
678 If your machine uses on-demand dialup IP, this causes your system
679 to place a telephone call whenever you submit new mail, and whenever
680 Postfix retries to deliver delayed mail. To prevent such telephone
681 calls 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.
704 Use the command "<b>postconf sendmail_path</b>" to find out where the
705 Postfix sendmail command is located on your machine. </p>
706
707 <p> In order to find out if the mail queue is flushed, use something
708 like: </p>
709
710 <pre>
711 #!/bin/sh
712
713 # Start mail deliveries.
714 /usr/sbin/sendmail -q
715
716 # Allow deliveries to start.
717 sleep 10
718
719 # Loop until all messages have been tried at least once.
720 while mailq | grep '^[^ ]*\*' >/dev/null
721 do
722 sleep 10
723 done
724 </pre>
725
726 <p> If you have disabled <a href="#spontaneous_smtp">spontaneous
727 SMTP mail delivery</a>, you also need to run the "<b>sendmail -q</b>"
728 command every now and then while the dialup link is up, so that
729 newly-posted mail is flushed from the queue. </p>
730
731 </ul>
732
733 <h2><a name="fantasy">Postfix on hosts without a real Internet
734 hostname</a></h2>
735
736 <p> This section is for hosts that don't have their own Internet
737 hostname. Typically these are systems that get a dynamic IP address
738 via DHCP or via dialup. Postfix will let you send and receive mail
739 just fine between accounts on a machine with a fantasy name. However,
740 you cannot use a fantasy hostname in your email address when sending
741 mail into the Internet, because no-one would be able to reply to
742 your mail. In fact, more and more sites refuse mail addresses with
743 non-existent domain names. </p>
744
745 <p> Note: the following information is Postfix version dependent.
746 To 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
752 local fantasy email addresses by valid Internet addresses. This
753 mapping happens ONLY when mail leaves the machine; not when you
754 send mail between users on the same machine. </p>
755
756 <p> The following example presents additional configuration. You
757 need to combine this with basic configuration information as
758 discussed in the first half of this document. </p>
759
760 <blockquote>
761 <pre>
762 1 /etc/postfix/main.cf:
763 2 smtp_generic_maps = hash:/etc/postfix/generic
764 3
765 4 /etc/postfix/generic:
766 5 his (a] localdomain.local hisaccount (a] hisisp.example
767 6 her (a] localdomain.local heraccount (a] herisp.example
768 7 @localdomain.local hisaccount+local (a] 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 (a] localdomain.local</i> by his ISP
777 mail address, </p>
778
779 <li> <p> Line 6 replaces <i>her (a] localdomain.local</i> by her ISP
780 mail address, and </p>
781
782 <li> <p> Line 7 replaces other local addresses by his ISP account,
783 with an address extension of +<i>local</i> (this example assumes
784 that 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
790 tables Postfix supports, use the command "<b>postconf -m</b>". </p>
791
792 <p> Execute the command "<b>postmap /etc/postfix/generic</b>"
793 whenever 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
798 Internet addresses where possible, and to let Postfix map valid
799 Internet addresses to local fantasy addresses. With this, you can
800 send mail to the Internet and to local fantasy addresses, including
801 mail to local fantasy addresses that don't have a valid Internet
802 address of their own.</p>
803
804 <p> The following example presents additional configuration. You
805 need to combine this with basic configuration information as
806 discussed 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:
819 10 your-login-name your-account (a] your-isp.com
820 11
821 12 /etc/postfix/virtual:
822 13 your-account (a] 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
831 use a domain name that is already in use by real organizations
832 on the Internet. See RFC 2606 for examples of domain
833 names 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 (a] hostname.localdomain" to "your-account (a] your-isp.com".
837 This part is required. </p>
838
839 <li> <p> Lines 7, 12, 13: Deliver mail for "your-account (a] your-isp.com"
840 locally, instead of sending it to the ISP. This part is not required
841 but 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
847 tables Postfix supports, use the command "<b>postconf -m</b>". </p>
848
849 <p> Execute the command "<b>postmap /etc/postfix/canonical</b>"
850 whenever you change the canonical table. </p>
851
852 <p> Execute the command "<b>postmap /etc/postfix/virtual</b>"
853 whenever you change the virtual table. </p>
854
855 </body>
856
857 </html>
858