Cover V08, I13
Article
Listing 1
Listing 2

Listing 2: check_rcpt

  1  ######################################################################
  2  ###  check_rcpt -- check SMTP `RCPT TO:' command argument
  3  ######################################################################
  4  
  5  SLocal_check_rcpt
  6  Scheck_rcpt
  7  R$*            $: $1 $| $>"Local_check_rcpt" $1
  8  R$* $| $#$*        $#$2
  9  R$* $| $*        $@ $>"Basic_check_rcpt" $1
 10  
 11  SBasic_check_rcpt
 12  # check for deferred delivery mode
 13  R$*            $: < ${deliveryMode} > $1
 14  R< d > $*        $@ deferred
 15  R< $* > $*        $: $2
 16  
 17  R$*            $: $>ParseRecipient $1        strip relayable hosts
 18  
 19  # blacklist local users or any host from receiving mail
 20  R$*            $: <?> $1
 21  R<?> $+ < @ $=w >    $: <> <USER $1> <FULL $1@$2> <HOST $2> <$1 < @ $2 >>
 22  R<?> $+ < @ $* >    $: <> <FULL $1@$2> <HOST $2> <$1 < @ $2 >>
 23  R<?> $+            $: <> <USER $1> <$1>
 24  R<> <USER $+> $*    $: <$(access $1 $: $)> $2
 25  R<> <FULL $+> $*    $: <$(access $1 $: $)> $2
 26  R<OK> <FULL $+> $*    $: <$(access $1 $: $)> $2
 27  R<> <HOST $+> $*    $: <$(access $1 $: $)> $2
 28  R<OK> <HOST $+> $*    $: <$(access $1 $: $)> $2
 29  R<> <$*>        $: $1
 30  R<OK> <$*>        $: $1
 31  R<RELAY> <$*>        $: $1
 32  R<REJECT> $*        $#error $@ 5.2.1 $: "550 Mailbox disabled for this 
recipient" 33 R<$+> $* $#error $@ 5.2.1 $: $1 error from access db 34 35 # anything terminating locally is ok 36 R$+ < @ $=w > $@ OK 37 R$+ < @ $* $=R > $@ OK 38 R$+ < @ $* > $: $>LookUpDomain <$2> <?> <$1 < @ $2 >> 39 R<RELAY> $* $@ RELAY 40 R<$*> <$*> $: $2 41 42 43 # check for local user (i.e. unqualified address) 44 R$* $: <?> $1 45 R<?> $+ < @ $+ > $: <REMOTE> $1 < @ $2 > 46 # local user is ok 47 R<?> $+ $@ OK 48 R<$+> $* $: $2 49 50 # anything originating locally is ok 51 R$* $: <?> $&{client_name} 52 # check if bracketed IP address (forward lookup != reverse lookup) 53 R<?> [$+] $: <BAD> [$1] 54 # pass to name server to make hostname canonical 55 R<?> $* $~P $: <?> $[ $1 $2 $] 56 R<$-> $* $: $2 57 R$* . $1 strip trailing dots 58 R$@ $@ OK 59 R$=w $@ OK 60 R$* $=R $@ OK 61 R$* $: $>LookUpDomain <$1> <?> <$1> 62 R<RELAY> $* $@ RELAY 63 R<$*> <$*> $: $2 64 65 # check IP address 66 R$* $: $&{client_addr} 67 R$@ $@ OK originated locally 68 R0 $@ OK originated locally 69 R$=R $* $@ OK relayable IP address 70 R$* $: $>LookUpAddress <$1> <?> <$1> 71 R<RELAY> $* $@ RELAY relayable IP address 72 R<$*> <$*> $: $2 73 R$* $: [ $1 ] put brackets around it... 74 R$=w $@ OK ... and see if it is local 75 76 77 # anything else is bogus 78 R$* $#error $@ 5.7.1 $: "550 Relaying denied"