Commit | Line | Data |
---|---|---|
f25ecb3d EA |
1 | divert(-1) |
2 | # | |
3 | # Copyright (c) 1983 Eric P. Allman | |
cb1a7064 KB |
4 | # Copyright (c) 1988, 1993 |
5 | # The Regents of the University of California. All rights reserved. | |
f25ecb3d EA |
6 | # |
7 | # %sccs.include.redist.sh% | |
8 | # | |
9 | divert(0) | |
10 | ||
d8ebcd49 | 11 | VERSIONID(`@(#)proto.m4 8.3 (Berkeley) %G%') |
f25ecb3d | 12 | |
6f403f33 | 13 | MAILER(local)dnl |
f25ecb3d | 14 | |
576bbd75 EA |
15 | ifdef(`_OLD_SENDMAIL_', |
16 | `define(`_SET_96_', 6)dnl | |
d8ebcd49 EA |
17 | define(`_SET_97_', 7)dnl |
18 | define(`_SET_98_', 8)dnl', | |
e46fc989 | 19 | `# level 4 config file format |
576bbd75 EA |
20 | V4 |
21 | define(`_SET_96_', 96)dnl | |
d8ebcd49 EA |
22 | define(`_SET_97_', 97)dnl |
23 | define(`_SET_98_', 98)dnl') | |
242270da | 24 | |
f25ecb3d EA |
25 | ################## |
26 | # local info # | |
27 | ################## | |
28 | ||
7df175c3 EA |
29 | CP. |
30 | ||
dacf3c9f | 31 | Cwlocalhost |
5461a68b | 32 | ifdef(`USE_CW_FILE', |
dacf3c9f | 33 | `# file containing names of hosts for which we receive email |
a719f50c | 34 | CONCAT(`Fw', confCW_FILE)', `dnl') |
f25ecb3d EA |
35 | |
36 | ifdef(`UUCP_RELAY', | |
37 | `# UUCP relay host | |
8038f5d5 | 38 | CONCAT(DY, UUCP_RELAY) |
7df175c3 | 39 | CPUUCP |
a151c868 | 40 | |
f25ecb3d EA |
41 | ')dnl |
42 | ifdef(`BITNET_RELAY', | |
43 | `# BITNET relay host | |
44 | CONCAT(DB, BITNET_RELAY) | |
7df175c3 | 45 | CPBITNET |
a151c868 | 46 | |
f25ecb3d EA |
47 | ')dnl |
48 | ifdef(`CSNET_RELAY', | |
49 | `# CSNET relay host | |
50 | CONCAT(DC, CSNET_RELAY) | |
7df175c3 | 51 | CPCSNET |
a151c868 | 52 | |
d2e7dfa9 EA |
53 | ')dnl |
54 | ifdef(`FAX_RELAY', | |
55 | `# FAX relay host | |
56 | CONCAT(DF, FAX_RELAY) | |
7df175c3 | 57 | CPFAX |
d2e7dfa9 | 58 | |
f25ecb3d | 59 | ')dnl |
97dcbde7 EA |
60 | ifdef(`SMART_HOST', |
61 | `# "Smart" UUCP relay host | |
62 | CONCAT(DS, SMART_HOST) | |
f25ecb3d | 63 | |
8d95d628 EA |
64 | ')dnl |
65 | ifdef(`MAILER_TABLE', | |
66 | `# Mailer table (overriding domains) | |
67 | Kmailertable MAILER_TABLE | |
68 | ||
e653dde7 EA |
69 | ')dnl |
70 | ifdef(`DOMAIN_TABLE', | |
71 | `# Domain table (adding domains) | |
72 | Kdomaintable DOMAIN_TABLE | |
73 | ||
97dcbde7 | 74 | ')dnl |
f25ecb3d EA |
75 | # who I send unqualified names to (null means deliver locally) |
76 | CONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY)) | |
77 | ||
22bc0471 EA |
78 | # who gets all local email traffic ($R has precedence for unqualified names) |
79 | CONCAT(DH, ifdef(`MAIL_HUB', MAIL_HUB)) | |
80 | ||
97dcbde7 EA |
81 | # my official hostname ($w or $w.$D) |
82 | CONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D)) | |
83 | ||
84 | # who I masquerade as (can be $j) | |
85 | CONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j)) | |
86 | ||
45eb1b8f EA |
87 | # class L: names that should be delivered locally, even if we have a relay |
88 | # class E: names that should be exposed as from this host, even if we masquerade | |
3eb5f759 | 89 | CLroot |
45eb1b8f | 90 | CEroot |
3eb5f759 EA |
91 | undivert(5)dnl |
92 | ||
f25ecb3d | 93 | # operators that cannot be in local usernames (i.e., network indicators) |
1429c39b | 94 | CO @ % ifdef(`_NO_UUCP_', `', `!') |
f25ecb3d | 95 | |
6f403f33 EA |
96 | # a class with just dot (for identifying canonical names) |
97 | C.. | |
98 | ||
32014295 EA |
99 | ifdef(`_OLD_SENDMAIL_', `dnl', |
100 | `# dequoting map | |
101 | Kdequote dequote') | |
f25ecb3d | 102 | |
9863b6e1 EA |
103 | undivert(6)dnl |
104 | ||
a151c868 EA |
105 | ###################### |
106 | # Special macros # | |
107 | ###################### | |
108 | ||
109 | # SMTP initial login message | |
110 | CONCAT(De, confSMTP_LOGIN_MSG) | |
111 | ||
112 | # UNIX initial From header format | |
113 | CONCAT(Dl, confFROM_LINE) | |
114 | ||
115 | # my name for error messages | |
116 | CONCAT(Dn, confMAILER_NAME) | |
117 | ||
118 | # delimiter (operator) characters | |
119 | CONCAT(Do, confOPERATORS) | |
f25ecb3d | 120 | |
a151c868 EA |
121 | # format of a total name |
122 | CONCAT(Dq, ifdef(`confFROM_HEADER', confFROM_HEADER, | |
123 | ifdef(`_OLD_SENDMAIL_', `$g$?x ($x)$.', `$?x$x <$g>$|$g$.'))) | |
f25ecb3d | 124 | include(`../m4/version.m4') |
a151c868 EA |
125 | |
126 | ############### | |
127 | # Options # | |
128 | ############### | |
129 | ||
0b8c3ec1 EA |
130 | # strip message body to 7 bits on input? |
131 | CONCAT(O7, confSEVEN_BIT_INPUT) | |
a151c868 EA |
132 | |
133 | # wait (in minutes) for alias file rebuild | |
134 | CONCAT(Oa, confALIAS_WAIT) | |
135 | ||
136 | # location of alias file | |
137 | CONCAT(OA, ifdef(`ALIAS_FILE', ALIAS_FILE, /etc/aliases)) | |
138 | ||
63381843 EA |
139 | # minimum number of free blocks on filesystem |
140 | CONCAT(Ob, confMIN_FREE_BLOCKS) | |
141 | ||
a151c868 EA |
142 | # substitution for space (blank) characters |
143 | CONCAT(OB, confBLANK_SUB) | |
144 | ||
145 | # connect to "expensive" mailers on initial submission? | |
146 | CONCAT(Oc, confCON_EXPENSIVE) | |
147 | ||
148 | # checkpoint queue runs after every N successful deliveries | |
149 | CONCAT(OC, confCHECKPOINT_INTERVAL) | |
150 | ||
151 | # default delivery mode | |
152 | CONCAT(Od, confDELIVERY_MODE) | |
153 | ||
154 | # automatically rebuild the alias database? | |
155 | CONCAT(OD, confAUTO_REBUILD) | |
156 | ||
157 | # error message header/file */ | |
158 | ifdef(`confERROR_MESSAGE', | |
3ce008de | 159 | CONCAT(OE, confERROR_MESSAGE), |
a151c868 EA |
160 | #OE/etc/sendmail.oE) |
161 | ||
162 | # error mode | |
163 | ifdef(`confERROR_MODE', | |
3ce008de | 164 | CONCAT(Oe, confERROR_MODE), |
a151c868 EA |
165 | #Oep) |
166 | ||
167 | # save Unix-style "From_" lines at top of header? | |
168 | CONCAT(Of, confSAVE_FROM_LINES) | |
169 | ||
170 | # temporary file mode | |
171 | CONCAT(OF, confTEMP_FILE_MODE) | |
172 | ||
173 | # match recipients against GECOS field? | |
174 | CONCAT(OG, confMATCH_GECOS) | |
175 | ||
176 | # default GID | |
177 | CONCAT(Og, confDEF_GROUP_ID) | |
178 | ||
179 | # maximum hop count | |
180 | CONCAT(Oh, confMAX_HOP) | |
181 | ||
182 | # location of help file | |
183 | CONCAT(OH, ifdef(`HELP_FILE', HELP_FILE, /usr/lib/sendmail.hf)) | |
184 | ||
185 | # ignore dots as terminators in incoming messages? | |
186 | CONCAT(Oi, confIGNORE_DOTS) | |
187 | ||
188 | # Insist that the BIND name server be running to resolve names | |
189 | ifdef(`confBIND_OPTS', | |
190 | CONCAT(OI, confBIND_OPTS), | |
191 | #OI) | |
192 | ||
0b8c3ec1 EA |
193 | # deliver MIME-encapsulated error messages? |
194 | CONCAT(Oj, confMIME_FORMAT_ERRORS) | |
195 | ||
a151c868 EA |
196 | # Forward file search path |
197 | ifdef(`confFORWARD_PATH', | |
198 | CONCAT(OJ, confFORWARD_PATH), | |
199 | #OJ/var/forward/$u:$z/.forward.$w:$z/.forward) | |
200 | ||
201 | # open connection cache size | |
202 | CONCAT(Ok, confMCI_CACHE_SIZE) | |
203 | ||
204 | # open connection cache timeout | |
205 | CONCAT(OK, confMCI_CACHE_TIMEOUT) | |
206 | ||
b28237e4 EA |
207 | # use Errors-To: header? |
208 | CONCAT(Ol, confUSE_ERRORS_TO) | |
209 | ||
a151c868 EA |
210 | # log level |
211 | CONCAT(OL, confLOG_LEVEL) | |
212 | ||
213 | # send to me too, even in an alias expansion? | |
214 | CONCAT(Om, confME_TOO) | |
215 | ||
216 | # verify RHS in newaliases? | |
217 | CONCAT(On, confCHECK_ALIASES) | |
218 | ||
219 | # default messages to old style headers if no special punctuation? | |
220 | CONCAT(Oo, confOLD_STYLE_HEADERS) | |
221 | ||
4c230f32 EA |
222 | # SMTP daemon options |
223 | ifdef(`confDAEMON_OPTIONS', | |
224 | CONCAT(OO, confDAEMON_OPTIONS), | |
225 | #OOPort=esmtp) | |
226 | ||
63381843 EA |
227 | # privacy flags |
228 | CONCAT(Op, confPRIVACY_FLAGS) | |
229 | ||
a151c868 EA |
230 | # who (if anyone) should get extra copies of error messages |
231 | ifdef(`confCOPY_ERRORS_TO', | |
232 | CONCAT(OP, confCOPY_ERRORS_TO), | |
233 | #OPPostmaster) | |
234 | ||
235 | # slope of queue-only function | |
236 | ifdef(`confQUEUE_FACTOR', | |
237 | CONCAT(Oq, confQUEUE_FACTOR), | |
238 | #Oq600000) | |
239 | ||
240 | # queue directory | |
241 | CONCAT(OQ, ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue)) | |
242 | ||
243 | # read timeout -- now OK per RFC 1123 section 5.3.2 | |
e46fc989 EA |
244 | ifdef(`confREAD_TIMEOUT', |
245 | CONCAT(Or, confREAD_TIMEOUT), | |
246 | #Ordatablock=10m) | |
a151c868 EA |
247 | |
248 | # queue up everything before forking? | |
249 | CONCAT(Os, confSAFE_QUEUE) | |
250 | ||
251 | # status file | |
252 | CONCAT(OS, ifdef(`STATUS_FILE', STATUS_FILE, /etc/sendmail.st)) | |
253 | ||
254 | # default message timeout interval | |
255 | CONCAT(OT, confMESSAGE_TIMEOUT) | |
256 | ||
257 | # time zone handling: | |
258 | # if undefined, use system default | |
259 | # if defined but null, use TZ envariable passed in | |
260 | # if defined and non-null, use that info | |
261 | ifelse(confTIME_ZONE, `USE_SYSTEM', `#Ot', | |
262 | confTIME_ZONE, `USE_TZ', `', | |
263 | `CONCAT(Ot, confTIME_ZONE)') | |
264 | ||
265 | # default UID | |
266 | CONCAT(Ou, confDEF_USER_ID) | |
267 | ||
268 | # list of locations of user database file (null means no lookup) | |
bd00122c | 269 | OU`'ifdef(`confUSERDB_SPEC', `confUSERDB_SPEC') |
a151c868 | 270 | |
4c230f32 EA |
271 | # fallback MX host |
272 | ifdef(`confFALLBACK_MX', | |
273 | CONCAT(OV, confFALLBACK_MX), | |
274 | #OVfall.back.host.net) | |
275 | ||
d8ebcd49 EA |
276 | # if we are the best MX host for a site, try it directly instead of config err |
277 | CONCAT(Ow, confTRY_NULL_MX_LIST) | |
278 | ||
a151c868 EA |
279 | # load average at which we just queue messages |
280 | CONCAT(Ox, confQUEUE_LA) | |
281 | ||
282 | # load average at which we refuse connections | |
283 | CONCAT(OX, confREFUSE_LA) | |
284 | ||
285 | # work recipient factor | |
286 | ifdef(`confWORK_RECIPIENT_FACTOR', | |
287 | CONCAT(Oy, confWORK_RECIPIENT_FACTOR), | |
288 | #Oy30000) | |
289 | ||
290 | # deliver each queued job in a separate process? | |
291 | CONCAT(OY, confSEPARATE_PROC) | |
292 | ||
293 | # work class factor | |
294 | ifdef(`confWORK_CLASS_FACTOR', | |
295 | CONCAT(Oz, confWORK_CLASS_FACTOR), | |
296 | #Oz1800) | |
297 | ||
298 | # work time factor | |
299 | ifdef(`confWORK_TIME_FACTOR', | |
300 | CONCAT(OZ, confWORK_TIME_FACTOR), | |
301 | #OZ90000) | |
302 | ||
303 | ########################### | |
304 | # Message precedences # | |
305 | ########################### | |
306 | ||
307 | Pfirst-class=0 | |
308 | Pspecial-delivery=100 | |
97dcbde7 | 309 | Plist=-30 |
a151c868 EA |
310 | Pbulk=-60 |
311 | Pjunk=-100 | |
312 | ||
313 | ##################### | |
314 | # Trusted users # | |
315 | ##################### | |
316 | ||
317 | Troot | |
318 | Tdaemon | |
319 | Tuucp | |
320 | ||
321 | ######################### | |
322 | # Format of headers # | |
323 | ######################### | |
324 | ||
e0a38185 | 325 | H?P?Return-Path: $g |
576bbd75 | 326 | HReceived: $?sfrom $s $.$?_($_) $.by $j ($v/$Z)$?r with $r$. id $i; $b |
a151c868 EA |
327 | H?D?Resent-Date: $a |
328 | H?D?Date: $a | |
329 | H?F?Resent-From: $q | |
330 | H?F?From: $q | |
331 | H?x?Full-Name: $x | |
332 | HSubject: | |
333 | # HPosted-Date: $a | |
334 | # H?l?Received-Date: $b | |
335 | H?M?Resent-Message-Id: <$t.$i@$j> | |
336 | H?M?Message-Id: <$t.$i@$j> | |
f25ecb3d EA |
337 | #\f |
338 | ###################################################################### | |
339 | ###################################################################### | |
340 | ##### | |
341 | ##### REWRITING RULES | |
342 | ##### | |
343 | ###################################################################### | |
344 | ###################################################################### | |
345 | ||
da9b1c77 | 346 | undivert(9)dnl |
f25ecb3d EA |
347 | |
348 | ########################################### | |
349 | ### Rulset 3 -- Name Canonicalization ### | |
350 | ########################################### | |
755e2424 | 351 | S3 |
f25ecb3d | 352 | |
66fe2d65 EA |
353 | # handle null input and list syntax (translate to <@> special case) |
354 | R$@ $@ <@> | |
23ae62a0 | 355 | R$*:;$* $@ $1 :; <@> |
77e96a45 | 356 | |
f25ecb3d | 357 | # basic textual canonicalization -- note RFC733 heuristic here |
ce25e438 | 358 | R$*<$*>$*<$*>$* <$2>$3$4$5 strip multiple <> <> |
4850f6e1 | 359 | R$*<$*<$+>$*>$* <$3>$5 2-level <> nesting |
66fe2d65 | 360 | R$*<>$* $@ <@> MAIL FROM:<> case |
f25ecb3d EA |
361 | R$*<$+>$* $2 basic RFC821/822 parsing |
362 | ||
363 | # make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later | |
56ec6f89 | 364 | R@ $+ , $+ @ $1 : $2 change all "," to ":" |
f25ecb3d EA |
365 | |
366 | # localize and dispose of route-based addresses | |
576bbd75 | 367 | R@ $+ : $+ $@ $>_SET_96_ < @$1 > : $2 handle <route-addr> |
f25ecb3d EA |
368 | |
369 | # find focus for list syntax | |
576bbd75 | 370 | R $+ : $* ; @ $+ $@ $>_SET_96_ $1 : $2 ; < @ $3 > list syntax |
56ec6f89 | 371 | R $+ : $* ; $@ $1 : $2; list syntax |
f25ecb3d EA |
372 | |
373 | # find focus for @ syntax addresses | |
56ec6f89 EA |
374 | R$+ @ $+ $: $1 < @ $2 > focus on domain |
375 | R$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right | |
576bbd75 | 376 | R$+ < @ $+ > $@ $>_SET_96_ $1 < @ $2 > already canonical |
f25ecb3d | 377 | |
1429c39b EA |
378 | ifdef(`_NO_UUCP_', `dnl', |
379 | `# convert old-style addresses to a domain-based address | |
576bbd75 EA |
380 | R$- ! $+ $@ $>_SET_96_ $2 < @ $1 .UUCP > resolve uucp names |
381 | R$+ . $- ! $+ $@ $>_SET_96_ $3 < @ $1 . $2 > domain uucps | |
382 | R$+ ! $+ $@ $>_SET_96_ $2 < @ $1 .UUCP > uucp subdomains') | |
f25ecb3d EA |
383 | |
384 | # if we have % signs, take the rightmost one | |
56ec6f89 EA |
385 | R$* % $* $1 @ $2 First make them all @s. |
386 | R$* @ $* @ $* $1 % $2 @ $3 Undo all but the last. | |
576bbd75 | 387 | R$* @ $* $@ $>_SET_96_ $1 < @ $2 > Insert < > and finish |
f25ecb3d EA |
388 | |
389 | # else we must be a local name | |
390 | ||
391 | ||
576bbd75 EA |
392 | ################################################ |
393 | ### Ruleset _SET_96_ -- bottom half of ruleset 3 ### | |
394 | ################################################ | |
f25ecb3d | 395 | |
45eb1b8f | 396 | # At this point, everything should be in a "local_part<@domain>extra" format. |
576bbd75 | 397 | S`'_SET_96_ |
f25ecb3d EA |
398 | |
399 | # handle special cases for local names | |
89906048 EA |
400 | R$* < @ localhost > $* $: $1 < @ $j . > $2 no domain at all |
401 | R$* < @ localhost . $m > $* $: $1 < @ $j . > $2 local domain | |
402 | ifdef(`_NO_UUCP_', `dnl', | |
403 | `R$* < @ localhost . UUCP > $* $: $1 < @ $j . > $2 .UUCP domain') | |
e653dde7 EA |
404 | ifdef(`DOMAIN_TABLE', ` |
405 | # look up unqualified domains in the domain table | |
406 | R$* < @ $- > $* $: $1 < @ $(domaintable $2 $) > $3', | |
407 | `dnl') | |
dacf3c9f | 408 | undivert(2)dnl |
80961747 | 409 | |
f5ade8ff EA |
410 | ifdef(`_NO_UUCP_', `dnl', |
411 | `ifdef(`UUCP_RELAY', | |
1ab66980 | 412 | `# pass UUCP addresses straight through |
56ec6f89 | 413 | R$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP > $3', |
1ab66980 | 414 | `# if really UUCP, handle it immediately |
6f403f33 | 415 | ifdef(`_CLASS_U_', |
56ec6f89 | 416 | `R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') |
6f403f33 | 417 | ifdef(`_CLASS_V_', |
56ec6f89 | 418 | `R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') |
6f403f33 | 419 | ifdef(`_CLASS_W_', |
56ec6f89 | 420 | `R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') |
6f403f33 | 421 | ifdef(`_CLASS_X_', |
56ec6f89 | 422 | `R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') |
6f403f33 | 423 | ifdef(`_CLASS_Y_', |
56ec6f89 | 424 | `R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') |
80961747 EA |
425 | |
426 | # try UUCP traffic as a local address | |
56ec6f89 | 427 | R$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP > $3 |
82960e03 | 428 | ifdef(`_OLD_SENDMAIL_', |
56ec6f89 EA |
429 | `R$* < @ $+ . $+ . UUCP > $* $@ $1 < @ $2 . $3 . > $4', |
430 | `R$* < @ $+ . . UUCP > $* $@ $1 < @ $2 . > $3')') | |
f5ade8ff | 431 | ') |
ad8d5f97 EA |
432 | ifdef(`_NO_CANONIFY_', |
433 | `# make sure local host names appear canonical | |
434 | R$* < @ $=w > $* $: $1 < @ $2 . > $3', | |
f5ade8ff | 435 | `# pass to name server to make hostname canonical |
ad8d5f97 EA |
436 | R$* < @ $* $~P > $* $: $1 < @ $[ $2 $3 $] > $4') |
437 | ||
dacf3c9f EA |
438 | undivert(8)dnl |
439 | ||
6f403f33 EA |
440 | # if this is the local hostname, make sure we treat is as canonical |
441 | R$* < @ $j > $* $: $1 < @ $j . > $2 | |
f25ecb3d | 442 | |
f25ecb3d EA |
443 | |
444 | ################################################## | |
445 | ### Ruleset 4 -- Final Output Post-rewriting ### | |
446 | ################################################## | |
447 | S4 | |
448 | ||
66fe2d65 | 449 | R$*<@> $@ $1 handle <> and list:; |
f25ecb3d EA |
450 | |
451 | # resolve numeric addresses to name if possible | |
6f403f33 EA |
452 | R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr |
453 | ||
454 | # strip trailing dot off possibly canonical name | |
455 | R$* < @ $+ . > $* $1 < @ $2 > $3 | |
f25ecb3d EA |
456 | |
457 | # externalize local domain info | |
6f403f33 EA |
458 | R$* < $+ > $* $1 $2 $3 defocus |
459 | R@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical | |
9d6b5c00 | 460 | R@ $* $@ @ $1 ... and exit |
f25ecb3d | 461 | |
1429c39b EA |
462 | ifdef(`_NO_UUCP_', `dnl', |
463 | `# UUCP must always be presented in old form | |
464 | R$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u') | |
f25ecb3d EA |
465 | |
466 | # delete duplicate local names | |
6f403f33 | 467 | R$+ % $=w @ $=w $1 @ $j u%host@host => u@host |
f25ecb3d EA |
468 | |
469 | ||
470 | ||
576bbd75 EA |
471 | ############################################################## |
472 | ### Ruleset _SET_97_ -- recanonicalize and call ruleset zero ### | |
473 | ### (used for recursive calls) ### | |
474 | ############################################################## | |
f25ecb3d | 475 | |
576bbd75 | 476 | S`'_SET_97_ |
f25ecb3d EA |
477 | R$* $: $>3 $1 |
478 | R$* $@ $>0 $1 | |
479 | ||
480 | ||
481 | ###################################### | |
482 | ### Ruleset 0 -- Parse Address ### | |
483 | ###################################### | |
484 | ||
485 | S0 | |
486 | ||
00948e88 | 487 | R<@> $#local $: <> special case error msgs |
0b8c3ec1 | 488 | R$*:;<@> $#error $@ USAGE $: "list:; syntax illegal for recipient addresses" |
89d51ef0 | 489 | |
56ec6f89 EA |
490 | ifdef(`_MAILER_smtp_', |
491 | `# handle numeric address spec | |
d8ebcd49 EA |
492 | ifdef(`_NO_CANONIFY_', |
493 | `R$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr', | |
494 | `dnl') | |
495 | R$* < @ [ $+ ] > $* $: $>_SET_98_ $1 < @ [ $2 ] > $3 numeric internet spec | |
496 | R$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 still numeric: send', | |
497 | `dnl') | |
f25ecb3d | 498 | |
5461a68b | 499 | # now delete the local info -- note $=O to find characters that cause forwarding |
576bbd75 EA |
500 | R$* < @ > $* $@ $>_SET_97_ $1 user@ => user |
501 | R< @ $=w . > : $* $@ $>_SET_97_ $2 @here:... -> ... | |
502 | R$* $=O $* < @ $=w . > $@ $>_SET_97_ $1 $2 $3 ...@here -> ... | |
8d95d628 EA |
503 | ifdef(`MAILER_TABLE', |
504 | ` | |
505 | # try mailer table lookup | |
7d426e19 | 506 | R$* < @ $-:$+ > $* $# $2 $@ $3 $: $1 @ $3 $4 found a match', |
8d95d628 | 507 | `dnl') |
f25ecb3d EA |
508 | |
509 | # short circuit local delivery so forwarded email works | |
2664707d | 510 | ifdef(`_LOCAL_NOT_STICKY_', |
576bbd75 EA |
511 | `R$=L < @ $=w . > $#local $: @ $1 special local names |
512 | R$+ < @ $=w . > $#local $: $1 dispose directly', | |
513 | `R$+ < @ $=w . > $: $1 < @ $2 @ $H > first try hub | |
82960e03 | 514 | ifdef(`_OLD_SENDMAIL_', |
7d426e19 EA |
515 | `R$+ < $+ @ $-:$+ > $# $3 $@ $4 $: $1 $2 yep .... |
516 | R$+ < $+ @ $+ > $#relay $@ $3 $: $1 $2 yep .... | |
22bc0471 EA |
517 | R$+ < $+ @ > $#local $: $1 nope, local address', |
518 | `R$+ < $+ @ $+ > $#local $: $1 yep .... | |
2664707d | 519 | R$+ < $+ @ > $#local $: @ $1 nope, local address')') |
d8ebcd49 EA |
520 | |
521 | # handle local hacks | |
522 | R$* $: $>_SET_98_ $1 | |
755e2424 EA |
523 | undivert(4)dnl |
524 | ||
979297f9 EA |
525 | ifdef(`_NO_UUCP_', `dnl', |
526 | `# resolve remotely connected UUCP links (if any) | |
708a514b | 527 | ifdef(`_CLASS_V_', |
7d426e19 | 528 | `R$* < @ $=V . UUCP > $* $#smtp $@ $V $: @ $V : $1 @ $2.UUCP $3', |
47523c33 | 529 | `dnl') |
708a514b | 530 | ifdef(`_CLASS_W_', |
7d426e19 | 531 | `R$* < @ $=W . UUCP > $* $#smtp $@ $W $: @ $W : $1 @ $2.UUCP $3', |
47523c33 | 532 | `dnl') |
708a514b | 533 | ifdef(`_CLASS_X_', |
7d426e19 | 534 | `R$* < @ $=X . UUCP > $* $#smtp $@ $X $: @ $X : $1 @ $2.UUCP $3', |
979297f9 | 535 | `dnl')') |
755e2424 | 536 | |
f25ecb3d EA |
537 | # resolve fake top level domains by forwarding to other hosts |
538 | ifdef(`BITNET_RELAY', | |
7d426e19 | 539 | `R$*<@$+.BITNET>$* $#smtp $@ $B $: $1 @ $2 . BITNET $3 user@host.BITNET', |
f25ecb3d EA |
540 | `dnl') |
541 | ifdef(`CSNET_RELAY', | |
7d426e19 | 542 | `R$*<@$+.CSNET>$* $#smtp $@ $C $: $1 @ $2 . CSNET $3 user@host.CSNET', |
f25ecb3d | 543 | `dnl') |
d2e7dfa9 | 544 | ifdef(`_MAILER_fax_', |
d8ebcd49 | 545 | `R$+ < @ $+ .FAX > $#fax $@ $2 $: $1 user@host.FAX', |
d2e7dfa9 | 546 | `ifdef(`FAX_RELAY', |
7d426e19 | 547 | `R$*<@$+.FAX>$* $#smtp $@ $F $: $1 @ $2 . FAX $3 user@host.FAX', |
d2e7dfa9 | 548 | `dnl')') |
f25ecb3d | 549 | |
755e2424 EA |
550 | ifdef(`UUCP_RELAY', |
551 | `# forward non-local UUCP traffic to our UUCP relay | |
7d426e19 | 552 | R$*<@$*.UUCP>$* $#smtp $@ $Y $: @ $Y : $1 @ $2.UUCP $3 uucp mail', |
56ec6f89 | 553 | `ifdef(`_MAILER_uucp_', |
755e2424 | 554 | `# forward other UUCP traffic straight to UUCP |
d8ebcd49 EA |
555 | R< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $2 @host.UUCP:... |
556 | R$+ < @ $+ .UUCP > $#uucp $@ $2 $: $1 user@host.UUCP', | |
755e2424 EA |
557 | `dnl')') |
558 | ||
e653dde7 EA |
559 | ifdef(`_MAILER_USENET_', ` |
560 | # addresses sent to net.group.USENET will get forwarded to a newsgroup | |
561 | R$+ . USENET $# usenet $: $1', | |
562 | `dnl') | |
563 | ||
97dcbde7 EA |
564 | ifdef(`_LOCAL_RULES_', |
565 | `# figure out what should stay in our local mail system | |
7d426e19 | 566 | R$* < @ $* > $* $#smtp $@ $2 $: $1 @ $2 $3 user@host.domain')') |
97dcbde7 EA |
567 | ifdef(`SMART_HOST', ` |
568 | # pass names that still have a host to a smarthost | |
569 | R$* < @ $* > $* $: < $S > $1 < @ $2 > $3 glue on smarthost name | |
d8ebcd49 EA |
570 | R< $- : $+ > $* $# $1 $@ $2 $: $3 if non-null, use it |
571 | R< $+ > $* $#suucp $@ $1 $: $2 if non-null, use it | |
572 | R<> $* $: $1 else strip off gunk', | |
e653dde7 | 573 | |
97dcbde7 EA |
574 | `ifdef(`_LOCAL_RULES_', ` |
575 | # reject messages that have host names we do not understand | |
576 | R$* < @ $* > $* $#error $@ NOHOST $: Unrecognized host name $2', | |
e653dde7 EA |
577 | `ifdef(`_MAILER_smtp_', |
578 | `# deal with other remote names | |
579 | R$* < @ $* > $* $#smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain')')') | |
f25ecb3d | 580 | |
82960e03 | 581 | ifdef(`_OLD_SENDMAIL_', |
5461a68b | 582 | `# forward remaining names to local relay, if any |
37e8750f EA |
583 | R$=L $#local $: $1 special local names |
584 | R$+ $: $1 < @ $R > append relay | |
22bc0471 EA |
585 | R$+ < @ > $: $1 < @ $H > no relay, try hub |
586 | R$+ < @ > $#local $: $1 no relay or hub: local | |
576bbd75 | 587 | R$+ < @ $=w > $#local $: $1 we are relay/hub: local |
97dcbde7 | 588 | R$+ < @ $-:$+ > $# $2 $@ $3 $: $1 deliver to relay/hub |
0d8911b2 | 589 | R$+ < @ $+ > $#relay $@ $2 $: $1 deliver to relay/hub', |
ccfcf4aa EA |
590 | |
591 | `# if this is quoted, strip the quotes and try again | |
592 | R$+ $: $(dequote $1 $) strip quotes | |
576bbd75 | 593 | R$* $=O $* $@ $>_SET_97_ $1 $2 $3 try again |
ccfcf4aa EA |
594 | |
595 | # handle locally delivered names | |
37e8750f EA |
596 | R$=L $#local $: @ $1 special local names |
597 | R$+ $#local $: $1 regular local names | |
6f403f33 | 598 | |
56ec6f89 EA |
599 | ########################################################################### |
600 | ### Ruleset 5 -- special rewriting after aliases have been expanded ### | |
601 | ### (new sendmail only) ### | |
602 | ########################################################################### | |
f25ecb3d | 603 | |
6f403f33 | 604 | S5 |
f25ecb3d | 605 | |
32014295 EA |
606 | # see if we have a relay or a hub |
607 | R$+ $: $1 < @ $R > | |
22bc0471 | 608 | R$+ < @ > $: $1 < @ $H > no relay, try hub |
576bbd75 | 609 | R$+ < @ $=w > $@ $1 we are relay/hub: local |
97dcbde7 | 610 | R$+ < @ $-:$+ > $# $2 $@ $3 $: $1 send to relay or hub |
32014295 EA |
611 | ifdef(`_MAILER_smtp_', |
612 | `R$+ < @ $+ > $#relay $@ $2 $: $1 send to relay or hub')') | |
bc09d8d3 EA |
613 | ifdef(`MAILER_TABLE', |
614 | ` | |
615 | ||
d8ebcd49 EA |
616 | ################################################################### |
617 | ### Ruleset 90 -- try domain part of mailertable entry ### | |
618 | ### (new sendmail only) ### | |
619 | ################################################################### | |
bc09d8d3 EA |
620 | |
621 | S90 | |
b28237e4 | 622 | R<$- . $+ > $* $: < $(mailertable .$2 $) > $3 lookup |
bc09d8d3 | 623 | R<$- : $+ > $* $# $1 $@ $2 $: $3 check -- resolved? |
5ee21648 | 624 | R< . $+ > $* $@ $>90 <$1> $2 no -- strip & try again |
bc09d8d3 EA |
625 | R<$*> $* $@ $2 no match', |
626 | `dnl') | |
d8ebcd49 EA |
627 | |
628 | ################################################################### | |
629 | ### Ruleset _SET_98_ -- local part of ruleset zero (can be null) ### | |
630 | ################################################################### | |
631 | ||
632 | S`'_SET_98_ | |
633 | undivert(3)dnl | |
f25ecb3d EA |
634 | #\f |
635 | ###################################################################### | |
636 | ###################################################################### | |
637 | ##### | |
ec174858 | 638 | `##### MAILER DEFINITIONS' |
f25ecb3d EA |
639 | ##### |
640 | ###################################################################### | |
641 | ###################################################################### | |
f25ecb3d | 642 | undivert(7)dnl |