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