[comp.mail.sendmail] A quick question.

kcantrel@digi.UUCP (Keith Cantrell) (09/15/89)

Once I get sendmail into debug mode to verify parsing of addresses, what are
the rules I need to run an address through to completely simulate what a real
mail message goes through.

Thanks,

Keith

-----------------------------------------------------------------------
Keith Cantrell                    Phones:  hm: 214-492-1088
Apollo Computer                            wk: 214-519-2399 @ DSC 
A Subsidiary of Hewlett-Packard
USMAIL:                          EMAIL:
2100 Sonata Ln                   cantrell@attctc.DALLAS.TX.US
Carrollton TX 75007                           or
                                   ...!attctc!digi!kcantrel

My opinions are my own, and do not reflect those of my employer.
-----------------------------------------------------------------------

hubcap@hubcap.clemson.edu (Mike Marshall) (09/15/89)

From article <220@digi.UUCP>, by kcantrel@digi.UUCP (Keith Cantrell):
> 
> Once I get sendmail into debug mode to verify parsing of addresses, what are
> the rules I need to run an address through to completely simulate what a real
> mail message goes through.

Try this:

change Od in your cf so that mail gets queued instead of delivered in the
background. 

Send a piece of mail to the address you want to watch get parsed.

Crank up a script session, so you can capture everything in a file.

Say    sendmail -q -d21.12

Enough spooge will spew out to make your socks roll up and down. But if you 
print out the captured file and study it, you'll see exactly which rule does 
what when and maybe even why.

-Mike Marshall        hubcap@clemson.edu

ault@pawl.rpi.edu (Jim Ault) (09/15/89)

Try this script.  If you have egrep, this works great.  I use it
constantly, along with another small script that feeds addresses in
and grabs the output, so I can test a whole list of addresses by
putting the process in the background.  

Let me know if it is helpful to you.

---Jim Ault, ITS Postmaster, Rensselaer Polytechnic Inst, Troy NY, 12180
   Postmaster@rpi.edu    Jim_Ault@rpitsmts.BITNET   Jim_Ault@mts.rpi.edu
   518-276-2750 (voice)     ...uunet!rpi.edu!ault     518-276-2809 (fax)

------ cut the GREEN wire first! ------ No, cut the RED wire f>>BOOM<< ------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  cfdebug cftest debug.in
# Wrapped by post@imagine.pawl.rpi.edu on Fri Sep 15 11:44:26 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'cfdebug' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'cfdebug'\"
else
echo shar: Extracting \"'cfdebug'\" \(1343 characters\)
sed "s/^X//" >'cfdebug' <<'END_OF_FILE'
X#! /bin/sh
X#
X# This shell script runs sendmail in address test mode and converts the
X# debugging output to something more intelligible for helping debug sendmail.cf
X# files.
X# 
X# Pass the config file to use as $1  - /usr/lib/sendmail.cf by default
X#
X# Enter input of the form (same as for "sendmail -bt"):
X# 
X#       0 address1
X#       0 address2
X#       ...
X#       (eof)
X# 
X#
Xif [ $# -eq 0 ]
Xthen 
X	cf="/usr/lib/sendmail.cf" 
Xelse
X	cf=$1
Xfi
Xif [ ! -r $cf ]
Xthen
X	echo "File '$cf' not readable, exiting..."
X	exit
Xfi
Xsudo /usr/lib/sendmail -bt -C$cf -d21.12 |\
Xgrep -v -e '----- rule fails' |\
Xsed -e 's/-----trying rule:/R/' \
X    -e 's/"^P"/$*/g' \
X    -e 's/"^Q"/$+/g' \
X    -e 's/"^R"/$-/g' \
X    -e 's/"^S\([A-Za-z]\)"/$=\1/g' \
X    -e 's/"^T\([0-9]\)"/$\1/g' \
X    -e 's/"^U"/$#/' \
X    -e 's/"^V"/$\&/g' \
X    -e 's/"^W"/$:/g' \
X    -e 's/"^X"/$>/g' \
X    -e 's/"//g' |\
Xsed -e '/^R/s/[ 	]//g' \
X    -e '/matches:/s/[ 	]//g' -e 's/rulematches:/rule matches: /' \
X    -e '/rewritten as:/s/[ 	]//g' -e 's/rewrittenas:/rewritten as: /' \
X    -e '/returns:/s/[ 	]//g' \
X    -e 's/.*ruleset\([0-9]\)returns:/ruleset \1 returns: /' \
X    -e '/input:/s/[ 	]//g' \
X    -e 's/.*ruleset\(.*\)input:/ruleset \1 input: /'
X#
X# Compliments of the author:  Dan Long
X#                             CSNET Technical Staff
X#         		      long@sh.cs.net
END_OF_FILE
if test 1343 -ne `wc -c <'cfdebug'`; then
    echo shar: \"'cfdebug'\" unpacked with wrong size!
fi
chmod +x 'cfdebug'
# end of 'cfdebug'
fi
if test -f 'cftest' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'cftest'\"
else
echo shar: Extracting \"'cftest'\" \(293 characters\)
sed "s/^X//" >'cftest' <<'END_OF_FILE'
X#!/bin/sh
X# A script to put debug input a line at a time through cfdebug.  JRA 05/10/89
X# call like this (with the file sendmail.cf in the current directory):
X#  cftest < debug.in > debug.out &
Xwhile read line ; do
X  echo $line 
X  echo $line | cfdebug sendmail.cf | grep '0 returns: $#' 
Xdone
END_OF_FILE
if test 293 -ne `wc -c <'cftest'`; then
    echo shar: \"'cftest'\" unpacked with wrong size!
fi
chmod +x 'cftest'
# end of 'cftest'
fi
if test -f 'debug.in' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'debug.in'\"
else
echo shar: Extracting \"'debug.in'\" \(573 characters\)
sed "s/^X//" >'debug.in' <<'END_OF_FILE'
X0 user@bit.BITNET
X0 bit.BITNET!user
X0 some.random.domain!user
X0 user@LOCAL
X0 site!user@uunet.uu.net
X0 <@host1,@host2,@host3:a@b.com>
X0 uunet!site1!site2
X0 user@itsgw.rpi.edu
X0 user@blah.its.rpi.edu
X0 user@rpi.edu
X0 user@pawl.rpi.edu
X0 userxxxx@mts.rpi.edu
X0 blah!nyser!user
X0 uunet!itsgw!user
X0 uunet!rpi!postmaster
X0 uunet!itsgw!mts!userfred@some.where.edu
X0 itsgw!user@uunet.uu.net
X0 adobe!someone@decwrl.dec.com
END_OF_FILE
if test 573 -ne `wc -c <'debug.in'`; then
    echo shar: \"'debug.in'\" unpacked with wrong size!
fi
# end of 'debug.in'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
--------------end of shar file --------------
--
---Jim Ault, ITS Postmaster, Rensselaer Polytechnic Inst, Troy NY, 12180
   Postmaster@rpi.edu    Jim_Ault@rpitsmts.BITNET   Jim_Ault@mts.rpi.edu
   518-276-2750 (voice)     ...uunet!rpi.edu!ault     518-276-2809 (fax)

per@erix.ericsson.se (Per Hedeland) (09/19/89)

In article <6467@hubcap.clemson.edu> hubcap@hubcap.clemson.edu (Mike Marshall)
writes:
>From article <220@digi.UUCP>, by kcantrel@digi.UUCP (Keith Cantrell):
>> Once I get sendmail into debug mode to verify parsing of addresses, what are
>> the rules I need to run an address through to completely simulate what a real
>> mail message goes through.

>Try this:
>change Od in your cf so that mail gets queued instead of delivered in the
>background. 
>Send a piece of mail to the address you want to watch get parsed.
>Crank up a script session, so you can capture everything in a file.
>Say    sendmail -q -d21.12

I agree with the idea (after all, the only *real* authority on what happens is
sendmail doing "normal" execution:-). In particular, just feeding destinations
through set 0 isn't nearly enough, since I've found that it is often the
*sender* addresses that get mangled beyond comprehension... However, I prefer
this method - IMHO it's simpler, shows *everything* that happens, and your UA
doesn't get in the way (must be run as a "trusted" user, of course):

/usr/lib/sendmail -odi -d21.x -f'env_sender' 'env_recipient' < 'letter'

where 'letter' contains at least

From: 'head_sender'
To: 'head_recipient'

and, of course, all the 'env_sender' etc are replaced by the addresses that you
really want to test. I find that x=2 tells the essentials of what's happening,
increase it as needed; I believe x=19 is the worst you can get... The drawback
with all this is, of course, that the letter actually gets sent if possible,
i.e. be careful with how you choose the addresses (at least the env_ ones).

Regards
--Per Hedeland
per@erix.ericsson.se  or
per%erix.ericsson.se@uunet.uu.net  or
...uunet!erix.ericsson.se!per