handle quotes inside comments properly
[unix-history] / usr / src / usr.sbin / sendmail / cf / m4 / proto.m4
index 3cf230f..b21ce4e 100644 (file)
@@ -8,62 +8,80 @@ divert(-1)
 #
 divert(0)
 
 #
 divert(0)
 
-VERSIONID(`@(#)proto.m4        8.7 (Berkeley) %G%')
+VERSIONID(`@(#)proto.m4        8.21 (Berkeley) %G%')
 
 MAILER(local)dnl
 
 ifdef(`_OLD_SENDMAIL_',
 
 MAILER(local)dnl
 
 ifdef(`_OLD_SENDMAIL_',
-`define(`_SET_96_', 6)dnl
+`define(`_SET_95_', 5)dnl
+define(`_SET_96_', 6)dnl
 define(`_SET_97_', 7)dnl
 define(`_SET_97_', 7)dnl
-define(`_SET_98_', 8)dnl',
-`# level 4 config file format
-V4
+define(`_SET_98_', 8)dnl
+define(`confDOMAIN_NAME',
+       `ifdef(`NEED_DOMAIN', `$w.$d', `$w')')dnl',
+`# level 5 config file format
+V5
+define(`_SET_95_', 95)dnl
 define(`_SET_96_', 96)dnl
 define(`_SET_97_', 97)dnl
 define(`_SET_98_', 98)dnl')
 define(`_SET_96_', 96)dnl
 define(`_SET_97_', 97)dnl
 define(`_SET_98_', 98)dnl')
-ifdef(`confSMTP_MAILER',, `define(`confSMTP_MAILER', `esmtp')')dnl
-define(`_SMTP_', `confSMTP_MAILER')dnl for readability only
+ifdef(`confSMTP_MAILER',, `define(`confSMTP_MAILER', `smtp')')dnl
+ifdef(`confLOCAL_MAILER',, `define(`confLOCAL_MAILER', `local')')dnl
+ifdef(`confRELAY_MAILER',,
+       `define(`confRELAY_MAILER',
+               `ifdef(`_MAILER_smtp_', `relay',
+                       `ifdef(`_MAILER_uucp', `suucp', `unknown')')')')dnl
+define(`_SMTP_', `confSMTP_MAILER')dnl         for readability only
+define(`_LOCAL_', `confLOCAL_MAILER')dnl       for readability only
+define(`_RELAY_', `confRELAY_MAILER')dnl       for readability only
 
 ##################
 #   local info   #
 ##################
 
 
 ##################
 #   local info   #
 ##################
 
-CP.
-
 Cwlocalhost
 ifdef(`USE_CW_FILE',
 `# file containing names of hosts for which we receive email
 Cwlocalhost
 ifdef(`USE_CW_FILE',
 `# file containing names of hosts for which we receive email
-CONCAT(`Fw', confCW_FILE)', `dnl')
+Fw`'confCW_FILE',
+       `dnl')
+ifdef(`confDOMAIN_NAME', `
+# my official domain name
+Dj`'confDOMAIN_NAME',
+       `dnl')
+
+ifdef(`_NULL_CLIENT_ONLY_',
+`include(../m4/nullrelay.m4)m4exit',
+       `dnl')
+
+CP.
 
 ifdef(`UUCP_RELAY',
 `# UUCP relay host
 
 ifdef(`UUCP_RELAY',
 `# UUCP relay host
-CONCAT(DY, UUCP_RELAY)
+DY`'UUCP_RELAY
 CPUUCP
 
 ')dnl
 ifdef(`BITNET_RELAY',
 `#  BITNET relay host
 CPUUCP
 
 ')dnl
 ifdef(`BITNET_RELAY',
 `#  BITNET relay host
-CONCAT(DB, BITNET_RELAY)
+DB`'BITNET_RELAY
 CPBITNET
 
 ')dnl
 ifdef(`CSNET_RELAY',
 `# CSNET relay host
 CPBITNET
 
 ')dnl
 ifdef(`CSNET_RELAY',
 `# CSNET relay host
-CONCAT(DC, CSNET_RELAY)
+DC`'CSNET_RELAY
 CPCSNET
 
 ')dnl
 ifdef(`FAX_RELAY',
 `# FAX relay host
 CPCSNET
 
 ')dnl
 ifdef(`FAX_RELAY',
 `# FAX relay host
-CONCAT(DF, FAX_RELAY)
+DF`'FAX_RELAY
 CPFAX
 
 ')dnl
 CPFAX
 
 ')dnl
-ifdef(`SMART_HOST',
-`# "Smart" UUCP relay host
-CONCAT(DS, SMART_HOST)
+# "Smart" relay host (may be null)
+DS`'ifdef(`SMART_HOST', SMART_HOST)
 
 
-')dnl
 ifdef(`MAILER_TABLE',
 `# Mailer table (overriding domains)
 Kmailertable MAILER_TABLE
 ifdef(`MAILER_TABLE',
 `# Mailer table (overriding domains)
 Kmailertable MAILER_TABLE
@@ -75,16 +93,13 @@ Kdomaintable DOMAIN_TABLE
 
 ')dnl
 # who I send unqualified names to (null means deliver locally)
 
 ')dnl
 # who I send unqualified names to (null means deliver locally)
-CONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY))
+DR`'ifdef(`LOCAL_RELAY', LOCAL_RELAY)
 
 # who gets all local email traffic ($R has precedence for unqualified names)
 
 # who gets all local email traffic ($R has precedence for unqualified names)
-CONCAT(DH, ifdef(`MAIL_HUB', MAIL_HUB))
-
-# my official hostname ($w or $w.$D)
-CONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D))
+DH`'ifdef(`MAIL_HUB', MAIL_HUB)
 
 # who I masquerade as (can be $j)
 
 # who I masquerade as (can be $j)
-CONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j))
+DM`'ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j)
 
 # class L: names that should be delivered locally, even if we have a relay
 # class E: names that should be exposed as from this host, even if we masquerade
 
 # class L: names that should be delivered locally, even if we have a relay
 # class E: names that should be exposed as from this host, even if we masquerade
@@ -109,20 +124,20 @@ undivert(6)dnl
 ######################
 
 # SMTP initial login message
 ######################
 
 # SMTP initial login message
-CONCAT(De, confSMTP_LOGIN_MSG)
+De`'confSMTP_LOGIN_MSG
 
 # UNIX initial From header format
 
 # UNIX initial From header format
-CONCAT(Dl, confFROM_LINE)
+Dl`'confFROM_LINE
 
 # my name for error messages
 
 # my name for error messages
-CONCAT(Dn, confMAILER_NAME)
+Dn`'confMAILER_NAME
 
 # delimiter (operator) characters
 
 # delimiter (operator) characters
-CONCAT(Do, confOPERATORS)
+Do`'confOPERATORS
 
 # format of a total name
 
 # format of a total name
-CONCAT(Dq, ifdef(`confFROM_HEADER', confFROM_HEADER,
-       ifdef(`_OLD_SENDMAIL_', `$g$?x ($x)$.', `$?x$x <$g>$|$g$.')))
+Dq`'ifdef(`confFROM_HEADER', confFROM_HEADER,
+       ifdef(`_OLD_SENDMAIL_', `$g$?x ($x)$.', `$?x$x <$g>$|$g$.'))
 include(`../m4/version.m4')
 
 ###############
 include(`../m4/version.m4')
 
 ###############
@@ -130,176 +145,176 @@ include(`../m4/version.m4')
 ###############
 
 # strip message body to 7 bits on input?
 ###############
 
 # strip message body to 7 bits on input?
-CONCAT(O7, confSEVEN_BIT_INPUT)
+O7`'confSEVEN_BIT_INPUT
 
 # wait (in minutes) for alias file rebuild
 
 # wait (in minutes) for alias file rebuild
-CONCAT(Oa, confALIAS_WAIT)
+Oa`'confALIAS_WAIT
 
 # location of alias file
 
 # location of alias file
-CONCAT(OA, ifdef(`ALIAS_FILE', ALIAS_FILE, /etc/aliases))
+OA`'ifdef(`ALIAS_FILE', ALIAS_FILE, /etc/aliases)
 
 # minimum number of free blocks on filesystem
 
 # minimum number of free blocks on filesystem
-CONCAT(Ob, confMIN_FREE_BLOCKS)
+Ob`'confMIN_FREE_BLOCKS
 
 # substitution for space (blank) characters
 
 # substitution for space (blank) characters
-CONCAT(OB, confBLANK_SUB)
+OB`'confBLANK_SUB
 
 # connect to "expensive" mailers on initial submission?
 
 # connect to "expensive" mailers on initial submission?
-CONCAT(Oc, confCON_EXPENSIVE)
+Oc`'confCON_EXPENSIVE
 
 # checkpoint queue runs after every N successful deliveries
 
 # checkpoint queue runs after every N successful deliveries
-CONCAT(OC, confCHECKPOINT_INTERVAL)
+OC`'confCHECKPOINT_INTERVAL
 
 # default delivery mode
 
 # default delivery mode
-CONCAT(Od, confDELIVERY_MODE)
+Od`'confDELIVERY_MODE
 
 # automatically rebuild the alias database?
 
 # automatically rebuild the alias database?
-CONCAT(OD, confAUTO_REBUILD)
+OD`'confAUTO_REBUILD
 
 
-# error message header/file */
+# error message header/file
 ifdef(`confERROR_MESSAGE',
 ifdef(`confERROR_MESSAGE',
-       CONCAT(OE, confERROR_MESSAGE),
+       OE`'confERROR_MESSAGE,
        #OE/etc/sendmail.oE)
 
 # error mode
 ifdef(`confERROR_MODE',
        #OE/etc/sendmail.oE)
 
 # error mode
 ifdef(`confERROR_MODE',
-       CONCAT(Oe, confERROR_MODE),
+       Oe`'confERROR_MODE,
        #Oep)
 
 # save Unix-style "From_" lines at top of header?
        #Oep)
 
 # save Unix-style "From_" lines at top of header?
-CONCAT(Of, confSAVE_FROM_LINES)
+Of`'confSAVE_FROM_LINES
 
 # temporary file mode
 
 # temporary file mode
-CONCAT(OF, confTEMP_FILE_MODE)
+OF`'confTEMP_FILE_MODE
 
 # match recipients against GECOS field?
 
 # match recipients against GECOS field?
-CONCAT(OG, confMATCH_GECOS)
+OG`'confMATCH_GECOS
 
 # default GID
 
 # default GID
-CONCAT(Og, confDEF_GROUP_ID)
+Og`'confDEF_GROUP_ID
 
 # maximum hop count
 
 # maximum hop count
-CONCAT(Oh, confMAX_HOP)
+Oh`'confMAX_HOP
 
 # location of help file
 
 # location of help file
-CONCAT(OH, ifdef(`HELP_FILE', HELP_FILE, /usr/lib/sendmail.hf))
+OH`'ifdef(`HELP_FILE', HELP_FILE, /usr/lib/sendmail.hf)
 
 # ignore dots as terminators in incoming messages?
 
 # ignore dots as terminators in incoming messages?
-CONCAT(Oi, confIGNORE_DOTS)
+Oi`'confIGNORE_DOTS
 
 # Insist that the BIND name server be running to resolve names
 ifdef(`confBIND_OPTS',
 
 # Insist that the BIND name server be running to resolve names
 ifdef(`confBIND_OPTS',
-       CONCAT(OI, confBIND_OPTS),
+       OI`'confBIND_OPTS,
        #OI)
 
 # deliver MIME-encapsulated error messages?
        #OI)
 
 # deliver MIME-encapsulated error messages?
-CONCAT(Oj, confMIME_FORMAT_ERRORS)
+Oj`'confMIME_FORMAT_ERRORS
 
 # Forward file search path
 ifdef(`confFORWARD_PATH',
 
 # Forward file search path
 ifdef(`confFORWARD_PATH',
-       CONCAT(OJ, confFORWARD_PATH),
+       OJ`'confFORWARD_PATH,
        #OJ/var/forward/$u:$z/.forward.$w:$z/.forward)
 
 # open connection cache size
        #OJ/var/forward/$u:$z/.forward.$w:$z/.forward)
 
 # open connection cache size
-CONCAT(Ok, confMCI_CACHE_SIZE)
+Ok`'confMCI_CACHE_SIZE
 
 # open connection cache timeout
 
 # open connection cache timeout
-CONCAT(OK, confMCI_CACHE_TIMEOUT)
+OK`'confMCI_CACHE_TIMEOUT
 
 # use Errors-To: header?
 
 # use Errors-To: header?
-CONCAT(Ol, confUSE_ERRORS_TO)
+Ol`'confUSE_ERRORS_TO
 
 # log level
 
 # log level
-CONCAT(OL, confLOG_LEVEL)
+OL`'confLOG_LEVEL
 
 # send to me too, even in an alias expansion?
 
 # send to me too, even in an alias expansion?
-CONCAT(Om, confME_TOO)
+Om`'confME_TOO
 
 # verify RHS in newaliases?
 
 # verify RHS in newaliases?
-CONCAT(On, confCHECK_ALIASES)
+On`'confCHECK_ALIASES
 
 # default messages to old style headers if no special punctuation?
 
 # default messages to old style headers if no special punctuation?
-CONCAT(Oo, confOLD_STYLE_HEADERS)
+Oo`'confOLD_STYLE_HEADERS
 
 # SMTP daemon options
 ifdef(`confDAEMON_OPTIONS',
 
 # SMTP daemon options
 ifdef(`confDAEMON_OPTIONS',
-       CONCAT(OO, confDAEMON_OPTIONS),
+       OO`'confDAEMON_OPTIONS,
        #OOPort=esmtp)
 
 # privacy flags
        #OOPort=esmtp)
 
 # privacy flags
-CONCAT(Op, confPRIVACY_FLAGS)
+Op`'confPRIVACY_FLAGS
 
 # who (if anyone) should get extra copies of error messages
 ifdef(`confCOPY_ERRORS_TO',
 
 # who (if anyone) should get extra copies of error messages
 ifdef(`confCOPY_ERRORS_TO',
-       CONCAT(OP, confCOPY_ERRORS_TO),
+       OP`'confCOPY_ERRORS_TO,
        #OPPostmaster)
 
 # slope of queue-only function
 ifdef(`confQUEUE_FACTOR',
        #OPPostmaster)
 
 # slope of queue-only function
 ifdef(`confQUEUE_FACTOR',
-       CONCAT(Oq, confQUEUE_FACTOR),
+       Oq`'confQUEUE_FACTOR,
        #Oq600000)
 
 # queue directory
        #Oq600000)
 
 # queue directory
-CONCAT(OQ, ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue))
+OQ`'ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue)
 
 # read timeout -- now OK per RFC 1123 section 5.3.2
 ifdef(`confREAD_TIMEOUT',
 
 # read timeout -- now OK per RFC 1123 section 5.3.2
 ifdef(`confREAD_TIMEOUT',
-       CONCAT(Or, confREAD_TIMEOUT),
+       Or`'confREAD_TIMEOUT,
        #Ordatablock=10m)
 
 # queue up everything before forking?
        #Ordatablock=10m)
 
 # queue up everything before forking?
-CONCAT(Os, confSAFE_QUEUE)
+Os`'confSAFE_QUEUE
 
 # status file
 
 # status file
-CONCAT(OS, ifdef(`STATUS_FILE', STATUS_FILE, /etc/sendmail.st))
+OS`'ifdef(`STATUS_FILE', STATUS_FILE, /etc/sendmail.st)
 
 # default message timeout interval
 
 # default message timeout interval
-CONCAT(OT, confMESSAGE_TIMEOUT)
+OT`'confMESSAGE_TIMEOUT
 
 # time zone handling:
 #  if undefined, use system default
 #  if defined but null, use TZ envariable passed in
 #  if defined and non-null, use that info
 ifelse(confTIME_ZONE, `USE_SYSTEM', `#Ot',
 
 # time zone handling:
 #  if undefined, use system default
 #  if defined but null, use TZ envariable passed in
 #  if defined and non-null, use that info
 ifelse(confTIME_ZONE, `USE_SYSTEM', `#Ot',
-       confTIME_ZONE, `USE_TZ', `',
-       `CONCAT(Ot, confTIME_ZONE)')
+       confTIME_ZONE, `USE_TZ', `Ot',
+       `Ot`'confTIME_ZONE')
 
 # default UID
 
 # default UID
-CONCAT(Ou, confDEF_USER_ID)
+Ou`'confDEF_USER_ID
 
 # list of locations of user database file (null means no lookup)
 OU`'ifdef(`confUSERDB_SPEC', `confUSERDB_SPEC')
 
 # fallback MX host
 ifdef(`confFALLBACK_MX',
 
 # list of locations of user database file (null means no lookup)
 OU`'ifdef(`confUSERDB_SPEC', `confUSERDB_SPEC')
 
 # fallback MX host
 ifdef(`confFALLBACK_MX',
-       CONCAT(OV, confFALLBACK_MX),
+       OV`'confFALLBACK_MX,
        #OVfall.back.host.net)
 
 # if we are the best MX host for a site, try it directly instead of config err
        #OVfall.back.host.net)
 
 # if we are the best MX host for a site, try it directly instead of config err
-CONCAT(Ow, confTRY_NULL_MX_LIST)
+Ow`'confTRY_NULL_MX_LIST
 
 # load average at which we just queue messages
 
 # load average at which we just queue messages
-CONCAT(Ox, confQUEUE_LA)
+Ox`'confQUEUE_LA
 
 # load average at which we refuse connections
 
 # load average at which we refuse connections
-CONCAT(OX, confREFUSE_LA)
+OX`'confREFUSE_LA
 
 # work recipient factor
 ifdef(`confWORK_RECIPIENT_FACTOR',
 
 # work recipient factor
 ifdef(`confWORK_RECIPIENT_FACTOR',
-       CONCAT(Oy, confWORK_RECIPIENT_FACTOR),
+       Oy`'confWORK_RECIPIENT_FACTOR,
        #Oy30000)
 
 # deliver each queued job in a separate process?
        #Oy30000)
 
 # deliver each queued job in a separate process?
-CONCAT(OY, confSEPARATE_PROC)
+OY`'confSEPARATE_PROC
 
 # work class factor
 ifdef(`confWORK_CLASS_FACTOR',
 
 # work class factor
 ifdef(`confWORK_CLASS_FACTOR',
-       CONCAT(Oz, confWORK_CLASS_FACTOR),
+       Oz`'confWORK_CLASS_FACTOR,
        #Oz1800)
 
 # work time factor
 ifdef(`confWORK_TIME_FACTOR',
        #Oz1800)
 
 # work time factor
 ifdef(`confWORK_TIME_FACTOR',
-       CONCAT(OZ, confWORK_TIME_FACTOR),
+       OZ`'confWORK_TIME_FACTOR,
        #OZ90000)
 
 ###########################
        #OZ90000)
 
 ###########################
@@ -325,7 +340,7 @@ Tuucp
 #########################
 
 H?P?Return-Path: $g
 #########################
 
 H?P?Return-Path: $g
-HReceived: $?sfrom $s $.$?_($_) $.by $j ($v/$Z)$?r with $r$. id $i; $b
+HReceived: $?sfrom $s $.$?_($_) $.by $j ($v/$Z)$?r with $r$. id $i$?u for $u$.; $b
 H?D?Resent-Date: $a
 H?D?Date: $a
 H?F?Resent-From: $q
 H?D?Resent-Date: $a
 H?D?Date: $a
 H?F?Resent-From: $q
@@ -352,16 +367,18 @@ undivert(9)dnl
 ###########################################
 S3
 
 ###########################################
 S3
 
-# handle null input and list syntax (translate to <@> special case)
+# handle null input (translate to <@> special case)
 R$@                    $@ <@>
 R$@                    $@ <@>
-R$*:;$*                        $@ $1 :; <@>
 
 # basic textual canonicalization -- note RFC733 heuristic here
 
 # basic textual canonicalization -- note RFC733 heuristic here
-R$*<$*>$*<$*>$*                <$2>$3$4$5                      strip multiple <> <>
+R$*<$*>$*<$*>$*                $2$3<$4>$5                      strip multiple <> <>
 R$*<$*<$+>$*>$*                <$3>$5                          2-level <> nesting
 R$*<>$*                        $@ <@>                          MAIL FROM:<> case
 R$*<$+>$*              $2                              basic RFC821/822 parsing
 
 R$*<$*<$+>$*>$*                <$3>$5                          2-level <> nesting
 R$*<>$*                        $@ <@>                          MAIL FROM:<> case
 R$*<$+>$*              $2                              basic RFC821/822 parsing
 
+# handle list:; syntax as special case
+R$*:;$*                        $@ $1 :; <@>
+
 # make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
 R@ $+ , $+             @ $1 : $2                       change all "," to ":"
 
 # make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
 R@ $+ , $+             @ $1 : $2                       change all "," to ":"
 
@@ -403,6 +420,9 @@ R$* < @ localhost > $*              $: $1 < @ $j . > $2             no domain at all
 R$* < @ localhost . $m > $*    $: $1 < @ $j . > $2             local domain
 ifdef(`_NO_UUCP_', `dnl',
 `R$* < @ localhost . UUCP > $* $: $1 < @ $j . > $2             .UUCP domain')
 R$* < @ localhost . $m > $*    $: $1 < @ $j . > $2             local domain
 ifdef(`_NO_UUCP_', `dnl',
 `R$* < @ localhost . UUCP > $* $: $1 < @ $j . > $2             .UUCP domain')
+R$* < @ [ $+ ] > $*            $: $1 < @ [[ $2 ]] > $3         catch [a.b.c.d]
+R$* < @ [ $=w ] > $*           $: $1 < @ $j . > $3             self-literal
+R$* < @ [[ $+ ]] > $*          $: $1 < @ [ $2 ] > $3           strip dbl [[]]
 ifdef(`DOMAIN_TABLE', `
 # look up unqualified domains in the domain table
 R$* < @ $- > $*                        $: $1 < @ $(domaintable $2 $) > $3',
 ifdef(`DOMAIN_TABLE', `
 # look up unqualified domains in the domain table
 R$* < @ $- > $*                        $: $1 < @ $(domaintable $2 $) > $3',
@@ -486,7 +506,7 @@ R$*                 $@ $>0 $1
 
 S0
 
 
 S0
 
-R<@>                   $#local $: <>                   special case error msgs
+R<@>                   $#_LOCAL_ $: <>                 special case error msgs
 R$*:;<@>               $#error $@ USAGE $: "list:; syntax illegal for recipient addresses"
 
 ifdef(`_MAILER_smtp_',
 R$*:;<@>               $#error $@ USAGE $: "list:; syntax illegal for recipient addresses"
 
 ifdef(`_MAILER_smtp_',
@@ -498,9 +518,9 @@ R$* < @ [ $+ ] > $* $#_SMTP_ $@ [$2] $: $1 @ [$2] $3        still numeric: send',
        `dnl')
 
 # now delete the local info -- note $=O to find characters that cause forwarding
        `dnl')
 
 # now delete the local info -- note $=O to find characters that cause forwarding
-R$* < @ > $*           $@ $>_SET_97_ $1                        user@ => user
-R< @ $=w . > : $*      $@ $>_SET_97_ $2                        @here:... -> ...
-R$* $=O $* < @ $=w . > $@ $>_SET_97_ $1 $2 $3                  ...@here -> ...
+R$* < @ > $*           $@ $>_SET_97_ $1                user@ => user
+R< @ $=w . > : $*      $@ $>_SET_97_ $2                @here:... -> ...
+R$* $=O $* < @ $=w . > $@ $>_SET_97_ $1 $2 $3          ...@here -> ...
 
 # handle local hacks
 R$*                    $: $>_SET_98_ $1
 
 # handle local hacks
 R$*                    $: $>_SET_98_ $1
@@ -512,15 +532,15 @@ R$* < @ $-:$+ > $*        $# $2 $@ $3 $: $1 @ $3 $4       found a match',
 
 # short circuit local delivery so forwarded email works
 ifdef(`_LOCAL_NOT_STICKY_',
 
 # short circuit local delivery so forwarded email works
 ifdef(`_LOCAL_NOT_STICKY_',
-`R$=L < @ $=w . >              $#local $: @ $1                 special local names
-R$+ < @ $=w . >                $#local $: $1                   dispose directly',
+`R$=L < @ $=w . >              $#_LOCAL_ $: @ $1                       special local names
+R$+ < @ $=w . >                $#_LOCAL_ $: $1                 dispose directly',
 `R$+ < @ $=w . >               $: $1 < @ $2 @ $H >             first try hub
 ifdef(`_OLD_SENDMAIL_',
 `R$+ < $+ @ $-:$+ >    $# $3 $@ $4 $: $1 $2            yep ....
 R$+ < $+ @ $+ >                $#relay $@ $3 $: $1 $2          yep ....
 `R$+ < @ $=w . >               $: $1 < @ $2 @ $H >             first try hub
 ifdef(`_OLD_SENDMAIL_',
 `R$+ < $+ @ $-:$+ >    $# $3 $@ $4 $: $1 $2            yep ....
 R$+ < $+ @ $+ >                $#relay $@ $3 $: $1 $2          yep ....
-R$+ < $+ @ >           $#local $: $1                   nope, local address',
-`R$+ < $+ @ $+ >               $#local $: $1                   yep ....
-R$+ < $+ @ >           $#local $: @ $1                 nope, local address')')
+R$+ < $+ @ >           $#_LOCAL_ $: $1                 nope, local address',
+`R$+ < $+ @ $+ >               $#_LOCAL_ $: $1                 yep ....
+R$+ < $+ @ >           $#_LOCAL_ $: @ $1                       nope, local address')')
 undivert(4)dnl
 
 ifdef(`_NO_UUCP_', `dnl',
 undivert(4)dnl
 
 ifdef(`_NO_UUCP_', `dnl',
@@ -558,41 +578,34 @@ R$+ < @ $+ .UUCP >        $#uucp $@ $2 $: $1              user@host.UUCP',
        `dnl')')
 ifdef(`_MAILER_usenet_', `
 # addresses sent to net.group.USENET will get forwarded to a newsgroup
        `dnl')')
 ifdef(`_MAILER_usenet_', `
 # addresses sent to net.group.USENET will get forwarded to a newsgroup
-R$+ . USENET           $# usenet $: $1',
+R$+ . USENET           $#usenet $: $1',
        `dnl')
 
 ifdef(`_LOCAL_RULES_',
 `# figure out what should stay in our local mail system
 R$* < @ $* > $*                $#smtp $@ $2 $: $1 @ $2 $3              user@host.domain')')
        `dnl')
 
 ifdef(`_LOCAL_RULES_',
 `# figure out what should stay in our local mail system
 R$* < @ $* > $*                $#smtp $@ $2 $: $1 @ $2 $3              user@host.domain')')
-ifdef(`SMART_HOST',
-`# pass names that still have a host to a smarthost
-R$* < @ $* > $*                $: < $S > $1 < @ $2 > $3        glue on smarthost name
-R< $- : $+ > $*                $# $1 $@ $2 $: $3               if non-null, use it
-R< $+ > $*             $#suucp $@ $1 $: $2             if non-null, use it
-R<> $*                 $: $1                           else strip off gunk',
-
-`# deal with other remote names
+# pass names that still have a host to a smarthost (if defined)
+R$* < @ $* > $*                $: $>_SET_95_ < $S > $1 < @ $2 > $3     glue on smarthost name
+
+# deal with other remote names
 ifdef(`_MAILER_smtp_',
 `R$* < @$* > $*                $#_SMTP_ $@ $2 $: $1 < @ $2 > $3                user@host.domain',
 ifdef(`_MAILER_smtp_',
 `R$* < @$* > $*                $#_SMTP_ $@ $2 $: $1 < @ $2 > $3                user@host.domain',
-`R$* < @$* > $*                $#error $@NOHOST $: Unrecognized host name $2')')
+`R$* < @$* > $*                $#error $@NOHOST $: Unrecognized host name $2')
 
 ifdef(`_OLD_SENDMAIL_',
 `# forward remaining names to local relay, if any
 
 ifdef(`_OLD_SENDMAIL_',
 `# forward remaining names to local relay, if any
-R$=L                   $#local $: $1                   special local names
-R$+                    $: $1 < @ $R >                  append relay
-R$+ < @ >              $: $1 < @ $H >                  no relay, try hub
-R$+ < @ >              $#local $: $1                   no relay or hub: local
-R$+ < @ $=w  >         $#local $: $1                   we are relay/hub: local
-R$+ < @ $-:$+ >                $# $2 $@ $3 $: $1               deliver to relay/hub
-R$+ < @ $+ >           $#relay $@ $2 $: $1             deliver to relay/hub',
+R$=L                   $#_LOCAL_ $: $1                 special local names
+R$+                    $: $>_SET_95_ < $R > $1                 try relay
+R$+                    $: $>_SET_95_ < $H > $1                 try hub
+R$+                    $#_LOCAL_ $: $1                 no relay or hub: local',
 
 `# if this is quoted, strip the quotes and try again
 R$+                    $: $(dequote $1 $)              strip quotes
 
 `# if this is quoted, strip the quotes and try again
 R$+                    $: $(dequote $1 $)              strip quotes
-R$* $=O $*             $@ $>_SET_97_ $1 $2 $3                  try again
+R$+ $=O $+             $@ $>_SET_97_ $1 $2 $3                  try again
 
 # handle locally delivered names
 
 # handle locally delivered names
-R$=L                   $#local $: @ $1                 special local names
-R$+                    $#local $: $1                   regular local names
+R$=L                   $#_LOCAL_ $: @ $1                       special local names
+R$+                    $#_LOCAL_ $: $1                 regular local names
 
 ###########################################################################
 ###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
 
 ###########################################################################
 ###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
@@ -602,12 +615,8 @@ R$+                        $#local $: $1                   regular local names
 S5
 
 # see if we have a relay or a hub
 S5
 
 # see if we have a relay or a hub
-R$+                    $: $1 < @ $R >
-R$+ < @ >              $: $1 < @ $H >                  no relay, try hub
-R$+ < @ $=w >          $@ $1                           we are relay/hub: local
-R$+ < @ $-:$+ >                $# $2 $@ $3 $: $1               send to relay or hub
-ifdef(`_MAILER_smtp_',
-`R$+ < @ $+ >          $#relay $@ $2 $: $1             send to relay or hub')')
+R$+                    $: $>_SET_95_ < $R > $1                 try relay
+R$+                    $: $>_SET_95_ < $H > $1                 try hub')
 ifdef(`MAILER_TABLE',
 `
 
 ifdef(`MAILER_TABLE',
 `
 
@@ -617,12 +626,22 @@ ifdef(`MAILER_TABLE',
 ###################################################################
 
 S90
 ###################################################################
 
 S90
-R<$- . $+ > $*         $: < $(mailertable .$2 $) > $3  lookup
+R<$- . $+ > $*         $: < $(mailertable .$2 $@ $1 $) > $3    lookup
 R<$- : $+ > $*         $# $1 $@ $2 $: $3               check -- resolved?
 R< . $+ > $*           $@ $>90 <$1> $2                 no -- strip & try again
 R<$*> $*               $@ $2                           no match',
 `dnl')
 
 R<$- : $+ > $*         $# $1 $@ $2 $: $3               check -- resolved?
 R< . $+ > $*           $@ $>90 <$1> $2                 no -- strip & try again
 R<$*> $*               $@ $2                           no match',
 `dnl')
 
+###################################################################
+###  Ruleset _SET_95_ -- canonify mailer:host syntax to triple ###
+###################################################################
+
+S`'_SET_95_
+R< > $*                        $@ $1                           strip off null relay
+R< $- : $+ > $*                $# $1 $@ $2 $: $3               try qualified mailer
+R< $=w > $*            $@ $2                           delete local host
+R< $+ > $*             $#_RELAY_ $@ $1 $: $2           use unqualified mailer
+
 ###################################################################
 ###  Ruleset _SET_98_ -- local part of ruleset zero (can be null)      ###
 ###################################################################
 ###################################################################
 ###  Ruleset _SET_98_ -- local part of ruleset zero (can be null)      ###
 ###################################################################