From: neal@smcnet.smc.edu (Neal Pollack, Telecomm Dept) Date: 23 May 90 18:35:29 GMT Subject: Sendmail Cheat Sheet Thanks to Bill Lewandowski wrl@wdl1.wdl.fac.com Added to by Neal Pollack neal@smc.edu Why confuse yourself when you can't find the docs? Trying to memorize all of the sendmail flags and rules can seriously damage the average human brain. Use a cheat sheet. Maybe others will continue to add and repost, till this becomes truly complete. I keep a copy in the .cf file. # MAILER OPTIONS # # f - this mailer wants a "-f from" line # r - this mailer wants a "-r from" line # S - call mailer as root # n - do not insert a From line # l - this mailer is local so final delevery will be made # s - strip quote characters from addresses # m - this mailer can send to more than one user on host # in single transaction # F - this mailer wants a From or Resent-From line(s) # D - this mailer wants a Date line in header # M - this mailer wants a Message-Id header line # x - this mailer wants a "Full-Name" header line # P - this mailer wants a "Return-Path" header line # u - upper case should be preserved in user names # h - upper case should be preserved in host names # A - this is an arpanet compatable mailer, use approprate flags # U - use unix style "From" lines with "remote from" # e - this is an "expensive" mailer # X - this mailer uses the "hidden dot" algorithm from RFC821 # L - limit line lengths as specified in RFC821 # I - this mailer will be speaking SMTP to another sendmail # C - if mail received from mailer with this flag set, any # addresses that do not have a "@" in them will have # "@domain" added to them # E - escape lines beggining with "From" with a ">" # R - this mailer wants a "Received" line in header # # Sendmail's built-in macros: # # $a origin date in ARPANET format (in msg "Date:" line) # $b current date in ARPANET format # $c hop count # $d current date in unix (ctime) format # $f raw sender (from) address # $g translated sender address (relative to the recipient) # $h recipient host # $i the queue id # $m the domain name # $p sendmail's processid in decimal [not used herein] # $r protocol used # $s sender's hostname # $t the current time in seconds since 1/1/1970 (for msg ids) # $u is the recipient user # $v version # of sendmail # $w hostname # $x signature (full name) of sender # $y ttyid of terminal # $z home directory of recpient # R U L E S # --------- # The LEFT HAND SIDE: # $* match zero or more tokens # $+ match one or more tokens # $- match exactly one token # $=x match any token in class x # $~x match any token NOT in class x # The RIGHT HAND SIDE: # $n substitute indefinite token n from LHS # $[name$] canonicalize name (look up with gethostent(3) ) # $[[128.32.130.2]$] would become vangogh.berkeley.edu # $>n call rule set n, remainder of line substituted as usual, # then passed to rule set n. Final value of rule n then # becomes the substitution for this rule. # $#mailer resolve to "mailer", terminates, use only # in rule 0, ends sendmail, goes to mailer. # $@host specify "host" # $:user specify "user" # COMMAND LINE FLAGS: # some more common ones # # -n do not do aliasing or forwarding # -b# Set operation mode to #, where # is; # m deliver mail, default # a run in arpanet mode # s speak SMTP on INPUT side # d run as a daemon # t run in test mode # v just verify addresses, don't deliver # i initialize the alias database # p print the mail queue # z Freeze the configuration file # # -d(level) set debugging level # # -C (file) use an alternate configuration file. # # -q (time) Try to process the queue. If time is given, # sendmail will run the queue every "time" mins. # -- Neal Pollack - Santa Monica College Telecommunications Department N6YFM 1900 Pico Blvd., Santa Monica, CA 90405-1628 Voice: Work- 213-450-5150 x9845 Internet: neal@smc.edu UUCP: uunet!ucla-cs!smcnet!neal or ...!csun!smcnet!neal Return-Path: comp.mail.sendmail >From: nelson@sun.soe.clarkson.edu (Russ Nelson) Date: 31 May 90 15:25:05 GMT Subject: The algorithm for rewriting rules A ruleset is like a subroutine that sendmail calls when it wants an address transformed. Sendmail calls rules 0 through 4 (or 6, depending on your version) by itself. You can call other rulesets as subroutines. Specific mailers can call rulesets for the sender or recipient. I can't find the algorithm for the application of the rewriting rules. As best I can determine from a source, this is it: Apply a rule. If it matches, rewrite it and apply the same rule again. If it doesn't match, try the next rule. If you start a RHS with $:, then after rewriting, apply the NEXT rule. If you start a RHS with $@, then after rewriting, exit this ruleset. If you start a RHS with $#, then after rewriting, exit this ruleset, and ruleset zero will see the $#, and use that information to deliver the mail using the given mailer. The picture given in the documentation that looks roughly like this: /----> 0 ----> resolved address | | /---> 1 ---> S ---\ | | | --> 3 -----> D ---| |---> 4 ----> Message | | \---> 2 ---> R ---/ is terribly misleading. It should really looks like this: ---> 3 -------> 0 ----> resolved address /---> 1 ---> S ---\ | | ---> 3 -----> D ---| |---> 4 ----> Message | | \---> 2 ---> R ---/ My documentation is not clear on whether the envelope's recipient or the header's To: is used to deliver the message. -- --russ (nelson@clutx [.bitnet | .clarkson.edu]) Russ.Nelson@$315.268.6667 Violence never solves problems, it just changes them into more subtle problems >From: whm@arizona.edu (Bill Mitchell) Subject: List of 4.3BSD sendmail debugging flag values/actions Date: 8 May 87 01:33:09 GMT Organization: U of Arizona CS Dept, Tucson Once again I found myself fooling with sendmail and as usual, I couldn't locate my assorted sheets of notes about what debugging flags do what. I decided to bite the bullet and go through and make notes about what all the flags do. It turned out to only take a couple of hours and the results were fairly reasonable, so I thought I'd pass this information along, for what it's worth. I don't think I overlooked any of the debug operations, but accidents will happen. Note that I didn't follow the logic back far enough to note the conditions when a particular debugging action would be executed. For example, -d0.15 prints the configuration table only if the configuration file is read. Here's the list. --------------- 0 -- main.c, recipient.c, util.c 0.1 -- don't fork in daemon mode, permit direct mailings to files, programs, and :includes:'s. 0.4 -- print names for this host 0.15 -- print configuration table 0.44 -- printav() -- prints addresses of elements 1 -- main.c, envelope.c 1.1 -- main() -- prints From person 2 -- main.c 2.1 -- finis() -- print exit status and envelope flags 5 -- clock.c 5.4 -- print calls to tick 5.5 -- print set/clrevent args 5.6 -- prints event queue on each tick 6 -- savemail.c 6.1 -- print savemail() error mode and return-to-sender information 6.5 -- trace states in savemail() state machine 8 -- domain.c 8.1 -- print various information regarding resolver operations 8.8 -- set RES_DEBUG 10,11,13 -- deliver.c 10.1 -- print various address information 11.1 -- print openmailer() args 13.1 -- sendall() -- print all addresses being sent to 13.3 -- sendall() -- prints each addr in loop looking for failures 13.4 -- sendall() -- follows above, printing who gets the error 15,16 -- daemon.c 15.1 -- print port and socket numbers in getrequests() 15.2 -- getrequests -- note forking/returning 15.15 -- activate network debugging on daemon socket 16.1 -- makeconnection() -- print host, addr, socket 16.15 -- print network debugging on daemon socket 18 -- usersmtp.c 18.1 -- note openmailer failure, note entry to reply, print smtpmessage() args 20 -- parseaddr.c 20.1 -- print parseaddr() arg and result 21 -- parseaddr.c 21.2 -- print rewrite() arg and result 21.3 -- note ruleset subroutine call 21.4 -- rewritten as ... 21.10 -- note rule failure 21.12 -- note rule attempt and success 21.15 -- print replacement string in hex chars (?) 21.35 -- print elements in pattern and subject 25 -- recipient.c 25.1 -- print sendto() arguments 26.1 -- print recipient in recipient() and duplicate suppression 27 -- alias.c 27.1 -- print arg to alias(), print info about alias, note failure to open alias file, print arg to forward() 30 -- collect.c 30.1 -- note EOH 30.2 -- print eatfrom arg 30.3 -- note addition of Apparently-To 31,32,33,14 -- headers.c 31.6 -- print chompheader argument 32.1 -- print collected header 33.1 -- print crackaddr arg and return value 14.2 -- print headers being commaized(?) 35 -- macro.c 35.9 -- print define() args 35.24 -- print expand() arg and return value 36 -- stab.c 36.5 -- print stab args, sym found/not found, entered 36.9 -- print hfunc value 37 -- readcf.c 37.1 -- print info re option setting/values 40,41,7,51 -- queue.c 40.1 -- note queue insertion and print queue contents 40.4 -- show queue file contents 41.2 -- note open failure on cf file. 7.1 -- print info on envelope assigned to queue file 7.2 -- print selected queue file name 51.4 -- don't unlink x file 45 -- envelope.c 45.1 -- print setsender argument 50 -- envelope.c 50.1 -- print dropenvelope argument 52 -- main.c 52.1 -- print i/o fd's for tty disconnection 52.5 -- don't disconnect --------------- Bill Mitchell whm@arizona.edu {allegra,cmcl2,ihnp4,noao}!arizona!whm