Rewriting: extraction of the first host or domain specification

The process of rewriting an address starts by extracting the first host/domain specification from the address. (Readers who are not familiar with RFC 822 address conventions are advised to read that  standard, at least in a cursory fashion, at this point in order to  understand the following discussion.) The order in which host/domain  specifications in the address are scanned is as follows:



 Hosts in source routes (read from left to right). 

 Hosts appearing to the right of the at sign. 

 Hosts appearing to the right of the last singleton percent sign. 

 Hosts appearing to the left of the first exclamation point. 



The order of the last two items are switched if the   channel option  is in effect on the channel that  is doing the address rewriting, that is, if the channel which is  attempting to enqueue the message is itself marked with the    channel option.9

Some highly hypothetical examples of addresses and the host name that would be extracted first are shown below:

Note that RFC 822 does not say anything about the interpretation of exclamation points, , and percent signs,  ,  in addresses. It is customary to interpret percent signs in the same manner as at signs,  ,  if no at sign is present, so this convention is adopted by the MTA.

The special interpretation of repeated percent signs is used to allow percent signs as part of local usernames, which is used in handling  PSIMail and other foreign mail system addresses. The interpretation of exclamation points conforms to RFC 976&#x27;s  "bang-style" address  conventions and makes it possible to use UUCP addresses with the MTA.

The order of interpretation of exclamation points vs. percent signs is not specified by either RFC 822 or RFC 976, so the    and   keywords can be used to control the order in which they are  applied by the channel doing the rewriting. Note that the default is more "standard", although the alternate setting may be useful  under some circumstances.

9For instance, if this is a message         being submitted to the SMTP port from a "local" client, then          the enqueueing channel is typically  , or   if the          user authenticates. If this is a message being submitted to the SMTP        SUBMIT port from a "local" client, then the enqueueing channel is  typically. If it is a message coming in from a remote Internet         user, then   usually it will be the    channel doing the          enqueueing.

See also:
 * bangoverpercent Option
 * nobangoverpercent Option
 * Typical TCPIP channels and servers
 * Application of rewrite rules to addresses