Contents:
The Syntax of -d
Debugging Behavior
Interpreting the Output
Pitfalls
Reference in Numerical Order
The 
sendmail
 program offers a command-line switch for investigating and solving mail problems. The debugging 
-d
 switch allows you to observe 
sendmail
's inner workings in detail.
The form for the 
-d
 command-line switch is
-dcategory.level,category.level,....-dANSIV8.8 and above
The 
-d
 may appear alone, or it may be followed by one or more 
category.level
 pairs separated by commas or, beginning with V8.8, by the word ANSI. We cover the 
category.level
 pairs first then ANSI.
The 
category
 limits debugging to an aspect of 
sendmail
 (such as queuing or aliasing). The 
level
 limits the verbosity of 
sendmail
 (with low levels producing the least output).
The 
category
 is either a positive integer or a range of integer values specified as
first-last
When 
category
 is a range, 
first
 is a positive integer that specifies the first category in the range. It is followed by a hyphen character (
-
) and then 
last
, a positive integer that specifies the last category in the range. The value of 
first
 must be less than the value of 
last
, or the range will be ignored.
The level is a positive integer. A level of 0 causes sendmail to produce no output for the category.
When the 
-d
 is specified with neither 
category
 nor 
level
, an internal 
sendmail
 default is used:
0-99.1
This default causes sendmail to set all the categories, from zero through 99 inclusive, to a level of 1.
When 
category
 is included but 
level
 is omitted, the value for 
level
 defaults to 1. When a dot (
.
) and 
level
 are included,  but 
category
 is omitted, the value for 
category
 defaults to 0.
The maximum value that may be specified for a single 
category
 is 99.  Any value specified above the maximum is reduced to the maximum. The maximum value for 
level
 is that of an 
unsigned char
 (255 decimal). Nondigits for the 
category
 or range evaluate to zero. Nondigits for the 
level
 evaluate to 1.
The 
level
 specifies the maximum amount of verbose output to produce. All levels below the 
level
 specified also produce output.
The expression that produces the maximum debugging output is
-d0-99.127
But beware that debugging levels of 100 or greater may cause 
sendmail
 to modify its behavior. (For example, one category at such a high level causes 
sendmail
 to not remove its temporary files.) For this reason, 
-d0-99.99
 is the maximum level recommended.
Debugging can be turned on from the command line and from within 
-bt
 rule-testing mode (see 
Section 38.7, "Add Debugging for Detail"
). If 
sendmail
 is wrongly compiled with SMTPDEBUG defined (see 
Section 18.8.42, SMTPDEBUG
), debugging can be turned on via an SMTP DEBUG command.
Beginning with V8.8 sendmail , a special debugging word can be specified at the command line to cause debugging output to become clearer:
-dANSIV8.8 and above
ANSI is case sensitive and must be the only argument following the 
-d
. If you wish to combine it with other debugging switches, you must specify them separately:
-dANSI -d0.4
ANSI causes defined macros, class macros, and operators to be displayed in reverse video:
R 
$+
        
$#
local 
$:
  
$1
This is truly a "hack." The escape code to highlight characters is hard-coded into sendmail . Your display must support ANSI standard escape sequences for this to work. There is no plan to use standard library support for this "aid to rule-set hackers."