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