Полезная информация


sendmailSearch this book
Previous: 32.4 PitfallsChapter 32
Class Macros
Next: 33. Database Macros

32.5 Alphabetized Reference

Prior to V8 sendmail, only the class w was used internally, but recently, more and more classes have been added to that internal list. Since internal class names always begin with a lowercase letter, you should always begin your own class names with an uppercase letter to avoid conflict.

Table 32.2 lists all the class macros used by sendmail as of version 8.8.4.

Table 32.2: All the Class Macros Used Internally by sendmail
$=eSection 32.5.1, $=eV8.7 and aboveEncode this Content-Transfer-Encoding:
$=kSection 32.5.2, $=kV8.6.5 and aboveThe local UUCP name
$=mSection 32.5.3, $=mV8.7 and aboveList of local domains
$=nSection 32.5.4, $=nV8.7 and aboveDon't encode these Content-Types
$=qSection 32.5.5, $=qV8.8 and aboveAlways Quoted-Printable encode Content-Type:
$=sSection 32.5.6, $=sV8.7 and abovePresume an RFC822 7-bit body
$=tSection 32.5.7, $=tV8.7 and aboveList trusted users
$=wSection 32.5.8, $=wAll versionsList of our other names

Note that these classes are really used internally by sendmail. Don't try to redefine their use in the configuration file. Such an attempt will be doomed to failure.

32.5.1 $=e

Encode this Content-Transfer-Encoding:

(V8.7 and above)

The F=7 delivery agent flag (see Section 30.8.4, F=7) determines whether MIME-encoded data should be converted from 8 to 7 bits. If the message is in 8-bit format and if it is going to a MIME-capable destination that requires 7-bit data, the message body will be converted to 7 bits by using either Quoted-Printable or Base64 (see Section 34.8.22, EightBitMode (8)).

Not all data types should be converted to 7 bits, however. The types that might possibly be converted are listed with the Content-Transfer-Encoding: header (see Section 35.10.8, Content-Transfer-Encoding:). One type that should not be converted, for example, is the quoted-printable type because it is already converted. Types that may be converted are 7bit, 8bit, and binary.

Beginning with version 8.7 sendmail, the class e is used to determine whether or not a type will be encoded. Only those values listed in this class will be encoded. When sendmail first starts, it initializes the list of values in class e to be

7bit 8bit binary

You may add types to this class, but you may never remove them.

Note that a type in class e may still be prevented from being encoded on the basis of the considerations imposed by class n. Also note that the actual encoding can be restricted to quoted printable by use of the class q.

32.5.2 $=k

The local UUCP name

(V8.6.5 and above)

When sendmail first begins to run, it figures out what your local UUCP node name is and assigns the result to the $k macro (see Section 31.10.21, $k). At the same time, it assigns the same name to this class k.

32.5.3 $=m

List of local domains

(V8.7 and above)

When sendmail first begins to run, it figures out what your DNS domain is and assigns the result to the $m macro (see Section 31.10.24, $m). The sendmail program then processes the configuration file. This gives you the opportunity to redefine $m. After that, sendmail assigns the final value in $m to the class m.

Unfortunately, as of V8.8 sendmail, the class macro m is not used by sendmail nor by any of the configuration files produced by the m4 technique. If you wish to have mail accepted as local under a variety of domains, use the domaintable FEATURE instead (see Section 19.6.10, FEATURE(domaintable)).

Suggested uses for class m might include screening mail with the check_compat rule set (see Section 29.10.4, "The check_compat Rule Set"), and detecting local domains by adding rules to rule set 0 with the LOCAL_RULE_0 m4 technique (see Section 19.6.32, LOCAL-RULE-0).

32.5.4 $=n

Don't encode these Content-Types

(V8.7 and above)

Although some MIME content types may be converted to 7 bits, not all types should be. Content types are defined by the Content-Type: header (see Section 35.10.9, Content-Type:). For example, the type multipart/ should not be converted, whereas its component boundary separated parts probably should be. Conversion is done by encoding with either Quoted-Printable or Base64 (see Section 34.8.22).

Beginning with V8.7 sendmail, types that should not be encoded are those defined as members of the class n. When sendmail first starts to run, it defines the following list of values for class n:


As of this writing, no other useful values exist for this class.

Note that a type in class n may still be prevented from being encoded based on the considerations imposed by class e. Also note that the actual encoding can be restricted to Quoted-Printable by use of the class q.

32.5.5 $=q

Always Quoted-Printable encode Content-Type:

(V8.8 and above)

The EightBitMode (8) option (see Section 34.8.22) determines when and how 8-bit data will be encoded into a 7-bit format. Ordinarily, the decision to use Quoted-Printable as opposed to Base64 is made by examining the input stream and choosing Quoted-Printable if less than 1/8 of the first 4 kilobytes of data has the high bit set. Otherwise, encoding is with Base64.

Beginning with V8.8, sendmail offers the class q as the means to force the selection of Quoted-Printable. Just before scanning the input data, sendmail extracts the type and subtype from the Content-Type: header (see Section 35.10.9):

Content-Type: type/subtype ; ...

If the type is in the class q, the body will definitely be encoded with Quoted-Printable if encoding occurs. Also if a concatenation of type, a slash (/), and subtype is in class q, the body will definitely be encoded with Quoted-Printable.

When sendmail first begins to run, class q is empty. A reasonable value in most countries might be text/plain (although probably not in countries that use 16-bit characters, such as China). Other values for this class might be text or text/html.

32.5.6 $=s

Presume an RFC822 7-bit body

(V8.7 and above)

An email message as defined by RFC822 may not contain 8-bit data. Consequently, when the MIME Content-Type: header declares a message subtype that is rfc822, we immediately know that it will contain nothing that needs 8- to 7-bit encoding.

Content-Type: message/rfc822

As other message subtypes evolve, this assumption can safely be made about them too. So to make sendmail more adaptable, the s class was added beginning with V8.7. This class contains a list of subtypes that should be treated the same as rfc822. When sendmail first begins to run, it initializes that list to contain:


Other subtypes that may legitimately appear here might be partial or delivery-status.

Note that this provides only an initial hint to sendmail. The rfc822 subtype may itself contain MIME information that might require 8- to 7-bit encoding.

32.5.7 $=t

List trusted users

(V8.7 and above)

Trusted users are those who may run sendmail with the -f command line switch to specify who sent the message. Prior to V8.6 sendmail, such users had to be listed with the T command (see Section, "Declare trusted users (not V8.1 through V8.6)"). That command was ignored in V8.1 through V8.6, and with those versions anyone could use the -f switch. Beginning with V8.7 sendmail, the T command was reintroduced, but it now causes the list of trusted users to be added to the class t. Now, any user who uses the -f switch and who is not listed in class t will cause the following error message (see Section 35.10.35, X-Authentication-Warning:) to be included in the outgoing mail message:

X-Authentication-Warning: user set sender to other using -f

See the use_ct_file FEATURE (see Section 19.6.25, FEATURE(use-ct-file)) for an easy way to add users to this class using the m4 technique.

32.5.8 $=w

List of our other names

(All versions)

Before the sendmail program reads its configuration file, it calls gethostbyname(3) to find all the known aliases for the local machine. The argument given to gethostbyname(3) is the value of the $w macro that was derived from a call to gethostname(3) (see Section 31.10.40, $w).

Depending on the version of sendmail you are running, the aliases that are found will either be those from your /etc/hosts file or those found as additional A records in a DNS lookup. To see the aliases that sendmail found or to see what it missed and should have found, use the -d0.4 debugging switch (see Section 37.5.2, -d0.4). Any aliases that are found are printed as

aka: alias

Depending on your version of sendmail, each alias is either a hostname (such as rog.stan.edu) or an Internet IP number (such as []).

Many sendmail.cf files use the w class macro to define all the ways users might reference the local machine. This list must contain all names for the local machine as given in the /etc/hosts file and all names for the local host as listed in DNS (including CNAME and MX records). For example,

# All our routing identities
Cw server1 server2
# All our local aliases
Cw localhost mailhost tops-link print-router loghost
# DNS records
Cw serv-link
# We are a bitnet registered node
Cw bitserver

If you notice mail failing because users commonly misspell the local machine name (e.g., ol11l0 when they really mean o1ll10); you might want to consider adding that misspelled version to a Cw declaration.

An easy way to add hostnames to class w is with the use_cw_file FEATURE (see Section 19.6.26, FEATURE(use-cw-file)) of the m4 technique.

Previous: 32.4 PitfallssendmailNext: 33. Database Macros
32.4 PitfallsBook Index33. Database Macros