Cover V08, I13
Article
Listing 1
Listing 2

Listing 1: check_mail

  1  ######################################################################
  2  ###  check_mail -- check SMTP `MAIL FROM:' command argument
  3  ######################################################################
  4  
  5  SLocal_check_mail
  6  Scheck_mail
  7  R$*            $: $1 $| $>"Local_check_mail" $1
  8  R$* $| $#$*        $#$2
  9  R$* $| $*        $@ $>"Basic_check_mail" $1
 10  
 11  SBasic_check_mail
 12  # check for deferred delivery mode
 13  R$*            $: < ${deliveryMode} > $1
 14  R< d > $*        $@ deferred
 15  R< $* > $*        $: $2
 16  
 17  R<>            $@ <OK>
 18  R$*            $: <?> $>Parse0 $>3 $1        make domain canonical
 19  R<?> $* < @ $+ . > $*    <?> $1 < @ $2 > $3        strip trailing dots
 20  # handle non-DNS hostnames (*.bitnet, *.decnet, *.uucp, etc)
 21  R<?> $* < $* $=P > $*    $: <OK> $1 < @ $2 $3 > $4
 22  R<?> $* < @ $+ > $*    $: <? $(resolve $2 $: $2 <PERM> $) > $1 < @ $2 > $3
 23  R<? $* <$->> $* < @ $+ > $*
 24              $: <$2> $3 < @ $4 > $5
 25  
 26  # handle case of @localhost on address
 27  R<$+> $* < @localhost >    $: < ? $&{client_name} > <$1> $2 < @localhost >
 28  R<$+> $* < @localhost.$m >
 29              $: < ? $&{client_name} > <$1> $2 < @localhost.$m >
 30  R<$+> $* < @localhost.UUCP >
 31              $: < ? $&{client_name} > <$1> $2 < @localhost.UUCP >
 32  R<? $=w> <$+> $*    <?> <$2> $3
 33  R<? $+> <$+> $*        $#error $@ 5.5.4 $: "553 Real domain name required"
 34  R<?> <$+> $*        $: <$1> $2
 35  
 36  # lookup localpart (user@)
 37  R<$+> $* < @ $+ > $*    $: <USER $(access $2@ $: ? $) > <$1> $2 < @ $3 > $4
 38  # no match, try full address (user@domain rest)
 39  R<USER ?> <$+> $* < @ $* > $*
 40              $: <USER $(access $2@$3$4 $: ? $) > <$1> $2 < @ $3 > $4
 41  # no match, try address (user@domain)
 42  R<USER ?> <$+> $+ < @ $+ > $*
 43              $: <USER $(access $2@$3 $: ? $) > <$1> $2 < @ $3 > $4
 44  # no match, try (sub)domain (domain)
 45  R<USER ?> <$+> $* < @ $+ > $*
 46              $: $>LookUpDomain <$3> <$1> <>
 47  # check unqualified user in access database
 48  R<?> $*            $: <USER $(access $1@ $: ? $) > <?> $1
 49  # retransform for further use
 50  R<USER $+> <$+> $*    $: <$1> $3
 51  
 52  # handle case of no @domain on address
 53  R<?> $*            $: < ? $&{client_name} > $1
 54  R<?> $*            $@ <OK>                ...local unqualed ok
 55  R<? $+> $*        $#error $@ 5.5.4 $: "553 Domain name required"
 56                              ...remote is not
 57  # check results
 58  R<?> $*            $@ <OK>
 59  R<OK> $*        $@ <OK>
 60  R<TEMP> $*        $#error $@ 4.1.8 $: "451 Sender domain must resolve"
 61  R<PERM> $*        $#error $@ 5.1.8 $: "501 Sender domain must exist"
 62  R<RELAY> $*        $@ <RELAY>
 63  R<DISCARD> $*        $#discard $: discard
 64  R<REJECT> $*        $#error $@ 5.7.1 $: "550 Access denied"
 65  R<$+> $*        $#error $@ 5.7.1 $: $1        error from access db