Administering Mail and Messaging

Channel tables

A mail channel uses a channel table to determine whether the message will be delivered by the channel. If the address (or portion of an address, in some cases) can be matched by the table, then delivery will be performed by that channel's delivery agent.

The Mail Manager provides six types of channel tables, and builds channel rulesets in sendmail.cf, according to the table type. This topic discusses the types, their sendmail.cf implementations, and how they affect information passed in the ruleset 0 triple.

Look in name service

A name service lookup may be configured as a channel table. If a recipient address has a hostname part, then this hostname is looked up, using the built-in sendmail ``host'' map class. If the hostname can be resolved by name service, then a successful match is produced, and mail is delivered by the associated delivery agent. The lookup will be performed as configured for the resolver by /etc/resolv.conf, meaning that DNS, NIS, and /etc/hosts may all be used.

A ruleset named ``dns_TBL'' has been pre-coded in sendmail.cf to implement the lookup. If the address can be resolved by name service, then it simply tags the address to convey this to the calling ruleset.

A channel created with this type of table passes the hostname portion of the recipient address to the hostname component of the ruleset 0 triple (specified by the ``$@'' operator in the right hand side of the rule). sendmail also stores this value in its h macro, which can then be used in the command line arguments defined for the associated delivery agent. The value of the h macro is referenced by prefixing a ``$'' character before the macro name, as in ``$h''.

This may only be overridden by configuring a host which receives all of the mail for this channel, by forwarding. If this is the case, then the h macro is assigned the name of the forwarding host. The forwarding host can be configured in the Mail Manager by modifying the ``Forward all Channel Mail to'' attribute of a mail channel.

Match UUCP configuration

The channel table may be compiled from the /etc/uucp/Systems file. This file contains a list of known UUCP hosts. The Mail Manager creates a sendmail hash class database from this file, and a database macro named ``uucp'' has been predefined in /etc/sendmail.cf with the K configuration file command (see ``K: key file declaration'').

A ruleset named ``uucp_TBL'' has been pre-coded in sendmail.cf to implement the lookup. If the address has a hostname portion, and that hostname can be found in this channel table, then it simply tags the address to convey this to the calling ruleset.

Similar to the name service lookup table type, ``$h'' will be assigned the hostname portion of the recipient address. Again, this may only be overridden by configuring a host which is forwarded all mail for this channel. If this is the case, then the h macro is assigned the name of the forwarding host.

Match local users

This table determines whether an address is a local address. A ruleset named ``local_TBL'' has been pre-coded in sendmail.cf to implement the table. The rules match addresses that do not have a hostname portion, or addresses which have a hostname portion and that hostname is a name for the local host (that is, the hostname is a member of the sendmail class ``w''). For example, if the local host name is a.b.com, then both tom and tom@a.b.com would yield a successful match by this table. Note that this does not guarantee that the user actually exists on the local machine, only that the format of the address is that of a local user.

A channel which uses this type of table does not assign a value to the h macro (hostname portion of triple), unless a forwarding host is defined for the ``Forward all Channel Mail to'' attribute.

Match non-local users

This table determines whether an address is a remote address. A ruleset named ``remote_TBL'' has been pre-coded in sendmail.cf to implement the table. Its rules match addresses that have a hostname portion, where the hostname is not the name of the local host (that is, the hostname is not a member of sendmail class ``w'').

Similar to the name service and UUCP table types, ``$h'' will be assigned the hostname portion of the recipient address. Again, this may only be overridden by configuring a host which is forwarded all mail for this channel. If this is the case, then the h macro is assigned the name of the forwarding host.

Match unknown users

This table matches an address if either of the following is true:

  1. the address has a hostname portion, where the hostname is the name of the local host (that is, a member of the sendmail w macro), and the local portion of the address is an unknown user

  2. the address does not have a hostname portion, and the local portion is an unknown user
Because of the way which sendmail implements aliasing, this is a special case table, which is used for the baduser mail channel. In sendmail, any delivery agent with the ``F=A'' flag set will cause the address to undergo aliasing, which may result in a new local address. This means that sendmail will only do aliasing after a delivery agent has already been chosen. However, if an address makes it through aliasing unchanged, sendmail gives it to rule set 5, which may select a new delivery agent. Therefore, in order to determine whether a local address is an unknown user, it must first be resolved to a mail channel whose delivery agent does aliasing (the local mail channel), and the channel ruleset which does the table lookup must be called from ruleset 5.

The baduser channel is used to forward mail addressed to unknown (therefore ``bad'') users to another host. For example, if a message is addressed to bob, and no such account exists on the machine, then we can configure a channel which forwards this message to another host, which either does have an account for bob, or knows where to send mail addressed to bob.

However, consider another example where aliasing is involved. Suppose a message arrives addressed to sysowner, and no such account exists. But the name sysowner is really an alias for the user eric, who does have an account on the system. We would not want this message forwarded to the baduser host. This can only be accomplished by the previous scheme, whereby the address is first resolved to a local mail channel which does aliasing, before being looked up in the user database.

Thus, this channel table lookup is called from ruleset 5. A ruleset named ``baduser_TBL'' has been pre-coded in sendmail.cf to implement this table. It uses the built-in sendmail user class map to determine what users exist on the system.

In general, the baduser channel defines a forwarding host for mail to unknown users. In this case, the h macro is assigned the name of this forwarding host. If a forwarding host is not defined, then it is assumed that the channel will perform final, local delivery, and no value is assigned to the h macro.

File lookup

This table uses data which is contained within a sendmail map file to match addresses. The file consists of key/value pairings, similar to the domain table. However, the channel table file does not implement subdomain matching, nor does it allow a route to be specified in the value of the table entry: it simply maps one name to another.

The map file is compiled into a hash class sendmail database, created automatically when edited via the Mail Manager. It is defined in sendmail.cf by a K configuration file command, using a name based upon the name chosen for the channel. The channel ruleset is only concerned with addresses with a hostname portion. It then uses database macros to lookup that hostname portion in the table. The hostname is matched against the keys in the table file. If a successful match is found, the value of the table entry will be assigned to the hostname part of the ruleset 0 triple. Therefore, the new hostname may be passed to the delivery agent by using the the h macro in the command line arguments specified for the delivery program in the Mail Manager. The entire original address is assigned to the user portion of the ruleset 0 triple, and thus can be passed to delivery agents via the u macro. It is assumed that the delivery program is able to parse the ``$u'' value if it needs to determine the hostname which was looked up (the key).

For this type of channel table, a forwarding host is specified by putting the name of the forwarding host as the value for each channel table file entry, since this is the value which may be passed to the delivery program via ``$h''. Do not specify the forwarding host by modifying the ``Forward all Channel Mail to'' attribute of a mail channel in the Mail Manager.

Although the file may be hand-edited, it is recommended you use the editor available in the Mail Manager, which will automatically compile the database for the file. Otherwise, use /etc/mail/makemap to create the database.

An example channel table file entry might look as follows:

   a.b.c.com        gateway.com
The above entry causes mail addressed to host a.b.c.com to be delivered by the corresponding channel. ``$h'' would be gateway.com, and ``$u'' would have the complete recipient address as its value.
© 1999 The Santa Cruz Operation, Inc. All rights reserved.
UnixWare 7 Release 7.1.1 - 5 November 1999