More sendmail.cf

Many options and flags can be used in configuring the sendmail.cf file. All of the important configuration parameters are covered in "sendmail ". But if you are unlucky enough to have a configuration that requires you to tweak one of the more obscure parameters, you will find all of them in the following tables.

sendmail Macros

The sendmail.cf file contains a large number of macro variables. Macros are useful because they can store values specific to your configuration and yet be referenced by a macro name that is independent of your configuration. This makes it possible to use a configuration file that is essentially the same on many different systems simply by varying the value stored in the macro. This appendix lists all of the internal sendmail macros in two tables. Table E-7 lists all of the macros that use single-character names.

Table E-7. Macros with single-character names

Macro Contents
a The date and time the mail was sent.
b The current date in RFC 822 format.
B The name of the Bitnet relay.
c The number of times the mail has been forwarded.
C The name of the DECnet relay.
d The current date and time in ctime format.
E Reserved for an X.400 relay.
f The sender address.
F The name of the FAX relay.
g The sender address written as a full return address.
h The recipient host.
H The name of the mail hub.
i The queue identifier.
j The fully qualified domain name of the local computer.
k The local system's UUCP node name.
L The name of the LUSER_RELAY.
m The name of the local domain.
M The name used to masquerade outbound mail.
n The sender name used for error messages.
p The PID of the sendmail process running as a mail delivery agent.
r The protocol used when the message was first received.
R The name of the LOCAL_RELAY.
s The hostname of the sender's machine.
S The name of the SMART_HOST relay.
t A numeric representation of the current date and time.
u The username of the recipient.
U A local UUCP name that overrides the value of $k.
v The version number of sendmail that is running.
V The name of the UUCP relay for class V hosts.
w The hostname of the local system.
W The name of the UUCP relay for class W hosts.
x The full name of the sender.
X The name of the UUCP relay for class X hosts.
Y The name of the UUCP relay for all other hosts.
z The home directory of the recipient.
Z The version number.
_ Sender address validated by identd.

The current version of sendmail allows macros to have multi-character names. Table E-8 lists the macros that use long names.

Table E-8. Reserved macros with long names

Macro Contents
{auth_authen} Identity of the authenticated user.
{auth_author} Source of the authentication.
{auth_ssf} The number of bits in the encryption key used by AUTH.
{auth_type} The type of authentication mechanism used.
{bodytype} The values from the ESMTP BODY parameter.
{cert_issuer} The distinguished name of the certificate authority.
{cert_subject} The distinguished name of the subject of the certificate.
{cipher_bits} The length of the encryption key used for the connection.
{cipher} The encryption technique used for the connection.
{client_addr} The IP address of the remote client connected to TCP port 25.
{client_name} The canonical name of the client connected to TCP port 25.
{client_port} The source port number used by the remote client.
{client_resolve} The keyword OK, FAIL, Forged or TEMP that indicates the result of a reverse DNS lookup using the client's IP address.
{currHeader} The contents of the current header during header processing.
{daemon_addr} The IP address of the network interface from which the daemon accepts mail. Normally 0.0.0.0 to indicate all interfaces.
{daemon_family} The protocol family being used. Normally inet to indicate TCP/IP. Other values are inet6, iso, and ns.
{daemon_flags} The flags set by the DaemonPortOption command, if any.
{daemon_info} General information about the daemon.
{daemon_name} The daemon name, which is usually Daemon1 unless a daemon name is defined by the DaemonPortOptions command.
{daemon_port} The port that the daemon is listening on, usually 25.
{deliveryMode} The current delivery mode.
{envid} The DSN ENVID value from the Mail From: header.
{hdrlen} The length of the string stored in {currHeader}.
{hdr_name} The name of the current header during header processing.
{if_addr} The IP address of the network interface used by the current incoming connection.
{if_name} The hostname assigned to the network interface used by the current incoming connection.
{mail_addr} The user's mail address from the mail delivery triple created from the MAIL From: envelope header.
{mail_host} The hostname from the mail delivery triple created from the MAIL From: envelope header.
{mail_mailer} The mailer name from the mail delivery triple created from the MAIL From: envelope header.
{MessageIdCheck} The value from the incoming Message-Id: header.
{ntries} The number of delivery attempts.
{opMode} The operating mode from the sendmail command line.
{queue_interval} The length of time between queue runs defined by the -q command-line option.
{rcpt_addr} The user's mail address from the mail delivery triple created from the RCPT To: envelope header.
{rcpt_host} The hostname from the mail delivery triple created from the RCPT To: envelope header.
{rcpt_mailer} The mailer name from the mail delivery triple created from the RCPT To: envelope header.
{server_addr} The IP address of the remote server for the outgoing connection.
{server_name} The name of the remote server for the outgoing connection.
{tls_version} The TLS/SSL version used for the connection.
{verify} The result of the verification process.

sendmail Classes

As the previous tables show, sendmail has many internal macros. It also has several internal classes. Most of these classes still use single-character names. A few use the newer long names. The full list of internal classes is shown in Table E-9.

Table E-9. Internal sendmail classes

Name Contents
B Domain names included in the bestmx-is-local process.
E Usernames that should not be masqueraded.
G Domains that should be looked up in the genericstable.
L Local users that are not forwarded to MAIL_HUB or LOCAL_RELAY.
e Supported MIME Content-Transfer-Encodings. Initialized to bit, bit, and binary.
k The system's UUCP node names.
M Domains that should be masqueraded.
m All local domains for this host.
n MIME body types that should never be 8- to 7-bit encoded. Initialized to multipart/signed.
q MIME Content-Types that should not be Base64-encoded. Initialized to text/plain.
N Hosts and domains that should not be masqueraded.
O Characters that cannot be used in local usernames.
P Pseudo-domain names, such as REDIRECT.
R Domains for which this system will relay mail.
s MIME message subtypes that can be processed recursively. Initialized to rfc822.
t The list of trusted users.
U The UUCP hosts that are locally connected.
V The UUCP hosts reached via the relay defined by $V.
W The UUCP hosts reached via the relay defined by $W.
X The UUCP hosts reached via the relay defined by $X.
Y Directly connected "smart" UUCP hosts.
Z Directly connected UUCP hosts that use domain names.
. A literal dot (.).
[ A literal left bracket ([).
{LDAPRoute} A list of domains that can be rerouted based on LDAP lookups.
{VirtHost} A list of hosts and domains that are valid virtual hostnames.
w All hostnames this system will accept as its own.

sendmail Options

A large number of sendmail options can be set inside the sendmail configuration file. "sendmail " provides the syntax of the option command in Table 10-1 and several examples of options. The complete list of options is:

Table E-10. Timeout types

Type Waiting for Default
connect A connection to complete 1m
control A control socket transmission to complete 2m
iconnect The connection to the first host in a message 5m
initial Initial greeting message 5m
helo Reply to HELO or EHLO command 5m
mail Reply to MAIL command 10m
rcpt Reply to RCPT command 1h
datainit Reply to DATA command 5m
datablock Data block read 1h
datafinal Reply to terminating "." 1h
rset Reply to RSET command 5m
quit Reply to QUIT command 2m
misc Reply to NOOP and VERB commands 2m
ident IDENT protocol response 30s
fileopen Open on a forward or :include: file 60s
command Command read 1h
queuereturn Returning a queued message as undeliverable 5d
queuereturn.normal Returning a normal message from the queue as undeliverable 5d
queuereturn.non-urgent Returning a non-urgent message from the queue as undeliverable 7d
queuereturn.urgent Returning an urgent message from the queue as undeliverable 2d
queuewarn Warning that a message is still queued 4h
queuewarn.normal Warning that a normal message is still queued 4h
queuewarn.non-urgent Warning that a non-urgent message is still queued 12h
queuewarn.urgent Warning that an urgent message is still queued 1h
resolver.retrans A response to a resolver query 5s
resolver.retrans.first A response to the first resolver query 5s
resolver.retrans.normal A response to a normal resolver query 5s
resolver.retry Sets the number of times to retry a resolver query 4
resolver.retry.first Sets the number of times to retry the first resolver query 4
resolver.retry.normal Sets the number of times to retry a normal resolver query 4
hoststatus Removing stale host status 30m

See "sendmail " for examples of setting options.

sendmail Mailer Flags

Mailer flags are declared in the F field of the mailer definition. Each mailer flag is set by a single character that represents that flag. For example, F=lsDFMe sets six different flags. Table E-11 lists the single-character name and function of each flag.

Table E-11. sendmail mailer flags

Name Function
C Add @domain to addresses that do not have an @.
D The mailer wants a Date: header line.
E Add > to message lines that begin with From:.
e This is an expensive mailer. See sendmail option c.
F The mailer wants a From: header line.
f The mailer accepts an -f flag from trusted users.
h Preserve uppercase in hostnames.
I The mailer will be speaking SMTP to another sendmail.
L Limit the line lengths as specified in RFC 821.
l This is a local mailer.
M The mailer wants a Message-Id: header line.
m The mailer can send to multiple users in one transaction.
n Don't insert a Unix-style From: line in the message.
P The mailer wants a Return-Path: line.
R Use the MAIL FROM: return path rather than the return address.
r The mailer accepts an -r flag from trusted users.
S Don't reset the userid before calling the mailer.
s Strip quotes off of the address before calling the mailer.
U The mailer wants Unix-style From: lines.
u Preserve uppercase in usernames.
X Prepend a dot to lines beginning with a dot.
x The mailer wants a Full-Name: header line.

See "sendmail " for examples of mailer flag declaration within mailer definitions.

The sendmail K Command

The sendmail K command is used to define a database within the sendmail.cf file. The K command syntax is:

Kname type [arguments]

"sendmail " provides examples of defining and using a sendmail database, and it describes the K command syntax. This appendix lists the valid type values and arguments that can be used with a K command.

The type field of the K command identifies what kind of database is being defined. There are several internal database types that are specific to sendmail, and several external types that rely on external database libraries. Support for the external database types must be compiled into sendmail by explicitly specifying the supported database types using the confMAPDEF command in a devtools/OS or devtools/Site file used by Build to compile sendmail. See the example of compiling sendmail earlier in this appendix.

The possible values for type are:

Many of the possible type values do not refer to real databases. Several types are special values used only inside sendmail. Some refer to internal sendmail routines that are accessed from rewrite rules using the same syntax that would be used to access a database.

The argument that follows most of the real database types is a filename. The filename identifies the external file that contains the database. Only the basic filename is provided. sendmail adds an extension appropriate for the database type. For example, Krealname dbm /usr/etc/names becomes /usr/etc/names.db because db is the correct extension for dbm databases.

In addition to a filename, the arguments field can contain optional flags:

The full lists of database types and flags provided in this appendix will help you understand the K commands inserted into the sendmail.cf file by the m4 processor. Your own K commands will be much simpler. You will stick with a database type that is supported by your sendmail and makemap commands, and you will build simple databases designed to fulfill specific purposes. "sendmail " provides examples of such databases, and the next section contains some simple scripts used to build those example databases.

Sample script

In "sendmail ", the realnames database is used to rewrite login usernames to the "firstname dot lastname" format for outbound email. The script shown below builds the realnames database from the /etc/passwd file.

#! /bin/sh # # Eliminate "non-login" accounts grep -v ':*:' /etc/passwd | \ # Eliminate "exposed" usernames, i.e. usernames defined # in class E as names that should not be re-written grep -v ' root:' | \ # Replace delimiting colons with whitespace sed 's/:/ /g' | \ # Output the username followed by firstname.lastname awk '{ print $1, $5"."$6 }' > realnames # Build the realnames database makemap dbm realnames < realnames

Building realnames from the passwd file is completely dependent on the format of that file. The passwd file must have a consistent format for the GECOS field and a consistent way to identify a "non-user" account. A "non-user" account is not accessed by a user to log in or to collect email. It is normally a system account used by system or application software. A classic example is the uucp account. Every system has some way to mark that these accounts are not used for user logins. Some systems use an asterisk in the password field, while others use an exclamation mark, the letters NP, an x, or something else. The sample script assumes that an asterisk is used, which is the case on my Linux system. (My Solaris system uses an x.) Print out your passwd file to find out what it uses and modify the script accordingly.

The sample script also assumes that the first two values in the GECOS field are the user's first and last names separated by a blank. If the beginning of the GECOS field is in any other format, the script produces garbage. The procedure you use to add new users to your system should produce a consistent GECOS field. Inconsistency is the enemy of automation. The sample below shows a file that has inconsistencies, and the bad data it produces:

% cat /etc/passwd root:oRd1L/vMzzxno:0:1:System Administrator:/:/bin/csh nobody:*:65534:65534::/: daemon:*:1:1::/: sys:*:2:2::/:/bin/csh bin:*:3:3::/bin: uucp:*:4:8::/var/spool/uucppublic: news:*:6:6::/var/spool/news:/bin/csh ingres:*:7:7::/usr/ingres:/bin/csh audit:*:9:9::/etc/security/audit:/bin/csh craig:1LrpKlz8sYjw:198:102:Craig Hunt:/home/craig:/bin/csh dan:RSU.NYlKuFqzh2:214:885:Dan Scribner:/home/dan:/bin/csh becca:monfTHdnjj:101:102:"Becky_Hunt":/home/becca:/bin/csh dave:lniuhugfds:121:885:David H. Craig:/home/dave:/bin/csh kathy:TUVigddehh:101:802:Kathleen S McCafferty:/home/kathy:/bin/csh % build.realnames % cat realnames craig Craig.Hunt dan Dan.Scribner becca "Becky_Hunt"./home/becca dave David.H. kathy Kathleen.S

Your passwd file may have grown over time under the control of several different system administrators. It may be full of inconsistencies. If it is, clean it up before you run the script to build email aliases, and then maintain it consistently.