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