Website update for 4.70
[exim-website.git] / config.samples / C037
1 Date: Wed, 22 Nov 2000 17:51:42 -0500 (EST)
2 From: Dave C. <djc@microwave.com>
3
4 Ok.. Ive come up with something which might be worth including in the
5 cookbook. Credit where it is due, the idea for this came from Nigel's
6 C014..
7
8 I have a setup to support ETRN for a few small (ok, two) domains.
9 Currently it just leaves all the mail in the exim spool, and uses the
10 default exim etrn response to flush it out.
11
12 I don't like that - I agree with the opinion expressed on the list that
13 mail should be delivered somewhere else, and then shoved down an SMTP
14 session by some other program. Ive searched far and wide for something
15 suitable to do that shoving, and finally hit upon the only program I
16 trust to do that, handling errors and rejections correctly - exim
17 itself.
18
19 Nigel's solution for 'situation where a site I MX for has a known
20 outage', combined with a bit of bash scriptery, seems to form a neat
21 solution. (An intermittently connected host sort of falls under the
22 'known outage' category ;)
23
24 Without any further fluff, here are the details. Additional comments
25 appear below..
26
27 Either the real (intermittently connected) destination host needs to be
28 listed as the lowest MX (with the exim server as a less preferred) , or
29 the exim server needs to be the lowest MX, but have a router before the
30 lookuphost router which uses route_list or something appropriate to
31 normally deliver mail to the dialup host. The former is probably better
32 for a host which is usually connected and is only occasionally
33 disconnected (since other hosts would be able to delivery directly most
34 of the time, skipping an extra relay), while the latter would probably
35 work better for the converse ;) This paragraph actually applies anytime
36 you are using ETRN..
37
38 In either case, the routers below must precede whatever router handles
39 the normal direct-to-dialup-destination..
40
41 --
42
43 smtp_etrn_command = /etc/exim/etrn_script $domain
44
45 [- Content of /etc/exim/etrn_script: -]
46 #!/bin/sh
47  
48 # Where exim lives
49 EXIM=/usr/sbin/exim
50  
51 # Something appropriate to generate a temporary unique string 
52 UNIQ=`head -c100 /dev/urandom | md5sum | cut -f 1 -d" "`
53
54 arg=$1
55 domain=`echo $arg | sed 's/^\#//g'`
56  
57 if ( test -f /var/spool/etrn/${domain} ); then
58  exim_lock -q /var/spool/etrn/${domain} "mv /var/spool/etrn/${domain} /tmp/etrn-bsmtp-${UNIQ}"
59  ( cat /tmp/etrn-bsmtp-${UNIQ}
60    echo "QUIT" ) | $EXIM -bS -oMr etrn_requeue
61  rm -f /tmp/etrn-bsmtp-${UNIQ}
62 fi
63  
64 $EXIM -R $domain
65
66 # If you use smtp_etrn_serialize, the following ensures that the
67 # serialize hint is removed for the argument exactly as specified by
68 # the client (which might have an # prepended if they are issuing an
69 # ETRN argument as required by exim's default ETRN support
70
71 $EXIM -R $arg
72
73 [- end of etrn_script -]
74
75 [- exim transport -]
76
77 bsmtp_for_etrn:
78  driver=appendfile
79  file=/var/spool/etrn/${domain}
80  user=exim
81  bsmtp=domain
82  check_string = "."
83  escape_string = ".."
84  prefix = ""
85  suffix = ""
86
87 [- routers -]
88 [- You probably would want to put the domains in a file or a dbm and
89 [- adjused the 'domains' setting appropriately for both of these..
90
91 # If any message has already been delivered to the bsmtp file,
92 # this will detect the existence of the file and all messages will
93 # go there, regardless of age..
94 etrn_already:
95  driver = domainlist
96  transport = bsmtp_for_etrn
97  require_files = /var/spool/etrn/${domain}
98  domains = etrntest.somedomain.com
99  route_list = *
100  
101 # If a message has been on the queue for over the specified amount of
102 # time, this will catch it and drop it into the bsmtp file
103 etrn_delay:
104  driver = domainlist
105  transport = bsmtp_for_etrn
106  condition = "${if >{$message_age}{1800} {yes}{no}}"
107  domains = etrntest.somedomain.com
108  route_list = *
109
110 [- -]
111
112 Basically, this setup lets exim try to deliver to the real host for up
113 to whatever time is specified in the etrn_delay router. (1800 seconds =
114 30 minutes), and then delivers all waiting messages, and any further
115 messages, directly to a bsmtp file.. This setup uses one big BSMTP
116 file, it probably wouldnt be too complex to have it use seperate
117 files..
118
119 When the etrn_script runs, it locks and renames the bsmtp file, and
120 reinjects the messages to exim, which (presumably) will now be able to
121 deliver them. If it can't, then once they are too old they will again
122 be sent off to the bsmtp file.. (If for som reason this occurs over and
123 over without exim being able to deliver them, eventually the messages
124 will be returned with "too many Received headers"; this is a good
125 thing, since their age will never get high enough for them to be
126 returned by any retry rules)