包含在查找更多文档专项支持资源 | 以 PDF 格式下载本书 (218 KB)
Chapter 3 sendmail ReferenceThe sendmail program is a mail transport agent that uses a configuration file to provide aliasing and forwarding, automatic routing to network gateways, and flexible configuration. The Solaris operating environment supplies standard configuration files that most sites can use. Chapter 2, Setting Up and Administering Mail Services explains how to set up an electronic mail system using the standard files. This chapter describes some of the differences between the generic version of sendmail and the Solaris version. What's New with sendmailVersion 8.9 of sendmail has been included with the Solaris 7 release. Here is a list of the important or user-visible changes that are included in this new version:
Additional information on the Solaris version of sendmail can be found at http://www.sendmail.org/sun-specific/migration+sun.html. The New Configuration FilesIn order to customize your mail system, it can be necessary to re-configure sendmail. Earlier Solaris releases contained a large file that included many cryptic options, that needed to be manually edited to make any changes to the way sendmail functions. In the Solaris 7 release, a new configuration system has been included, which uses m4 to build the configuration file (see the m4(1) man page). Changes to the sendmail Command Line OptionsThe options listed in the following table are the new options for the Solaris 7 release. A complete description of these options can be found in sendmail, Second Edition, by Bryan Costales. Table 3-1 sendmail Command-Line Arguments Changes
Changes to the sendmail Configuration File OptionsThe options listed in the following table are the new configuration options for the Solaris 7 release. These options are sorted by their multicharacter name. If the option still has a single character name, it is displayed parenthetically. Many of the single character options supported in 2.6 are still supported in the Solaris 7 release. A complete description of these options can be found in sendmail, Second Edition, by Bryan Costales. Table 3-2 sendmail Configuration File Option Changes
Solaris sendmail DifferencesThis section describes some of the changes included in the Solaris version of sendmail as compared to the generic Berkeley version. Flags Used When Compiling sendmailThe following table lists the flags used when compiling the version of sendmail delivered with the Solaris 7 release. If your configuration requires other flags, then you need to download the source and recompile the binary yourself. Information about this process can be found at http://www.sendmail.org.
Alternative sendmail CommandsThe Solaris release does not include all of the command synonyms that are provided in the generic release from Berkley. This table includes a complete list of the command aliases, whether they are included in the Solaris release, and how to generate the same behavior using sendmail. Table 3-3 Alternate sendmail Commands
Define Configuration File VersionThe new version of sendmail (version 8) includes a new configuration option which defines the version of the sendmail.cf file. This will allow older configuration files to be used with Version 8 sendmail. You can set the version level to values between 0 and 8. You can also define the vendor. Either Berkeley or Sun are valid vendor options. If the V option is not defined in the configuration file, the default setting is V1/Sun. If a version level is specified but no vendor is defined, then Sun is used as the default vendor setting. Table 3-4 lists some of the valid options. Table 3-4 Configuration File Version Values
How Mail Addressing WorksThe path a mail message follows during delivery depends on the setup of the client system and the topology of the mail domain. Each additional level of mail hosts or mail domains can add one more round of alias resolution, but the routing process is basically the same on most hosts. You can set up a client system to receive mail locally or select a remote to receive the mail for the client system. Receiving mail locally is known as running sendmail in local mode. Local is the default mode for all mail servers and some clients. If the client is mounting /var/mail from a server, then the client is running sendmail in remote mode. Assuming that you are using the default rule set in the sendmail.cf file, the following examples show the route an email message takes. On a mail client in remote mode, a mail message will go through the following routing process:
On the mail server or a mail client in local mode, a mail message goes through the following routing process:
How sendmail Interacts With a Name ServiceMail domain is a concept used by the standard sendmail.cf file to determine whether mail should be delivered directly or through the mail host. Intra-domain mail is delivered through direct SMTP connection, while inter-domain mail is forwarded to a mail host. In a secure network, only a few selected hosts are authorized to generate packets targeted to external destinations. Even if a host has the IP address of the remote host external to the mail domain, this does not guarantee that an SMTP connection can be established. The standard sendmail.cf assumes the following:
Given these assumptions, it is the responsibility of the mail host to deliver or forward inter-domain mail. Setting Up sendmail Requirements for Name Servicessendmail imposes various requirements on name services. This section explains these requirements and how to satisfy them. For more information, refer to the in.named(1M), NIS+(1), nisaddent(1M), and nsswitch.conf(4) man pages. Establishing the Mail Domain Name with a Name ServiceThe mail domain name must be a suffix of the name service domain. For example, if the domain name of the name service is A.B.C.D, then the mail domain name could be one of the following:
When first established, the mail domain name is often identical to the name service domain. As the network grows larger, the name service domain can be divided into smaller pieces to make the name service more manageable. However, the mail domain often remains undivided to provide consistent aliasing. Host Name Space DataThe host table or map in the name service must be set up to support three types of gethostbyname() queries:
Two additional rules about the host name space need to be followed to properly establish the sendmail services within a name space.
Configuration Issues with NIS and sendmailThis list includes all the configuration issues that you must resolve before using sendmail, when using NIS as your only name service. mail domain name -- If you are setting up NIS as the primary name service, sendmail automatically strips off the first component of the NIS domain name and uses the result as mail domain name. For example, ebs.admin.acme.com becomes admin.acme.com. mail host host name -- You must have a mailhost entry in the NIS host map. full host names -- The normal NIS setup does not "understand" the full host name. Rather than trying to make NIS understand the full host name, turn off this requirement from the sendmail side by editing the sendmail.cf file and replacing all occurrences of %l with %y. This turns off sendmail's inter-domain mail detection. As long as the target host can be resolved to an IP address, a direct SMTP delivery is attempted. Make sure that your NIS host map does not contain any host entry that is external to the current mail domain. Otherwise, you need to further customize the sendmail.cf file. matching full and short host names -- Follow the previous instructions on how to turn off gethostbyname() for a full host name. multiple NIS domains in one mail domain -- All NIS host maps under a common mail domain should have the same set of host entries. For example, the host map in the ebs.admin.acme.com domain should be the same as the host map in the esg.admin.acme.com. Otherwise, one address might work in one NIS domain but fail in the other NIS domain. Configuration Issues with NIS and DNS while Using sendmailThis list includes all the configuration issues that you must resolve before using sendmail, when using NIS with DNS as your name service. mail domain name -- If you are setting up NIS as the primary name service, sendmail automatically strips the first component of the NIS domain name and uses the result as mail domain name, for example, ebs.admin.acme.com becomes admin.acme.com. mailhost host name -- When the DNS forwarding feature is turned on, queries that NIS cannot resolve are forwarded to DNS, so there is no need for a mailhost entry in the NIS host map. full host names -- Although NIS does not "understand" full host names, DNS does. This requirement is satisfied when you follow the regular procedure for setting up NIS and DNS. matching full and short host names -- For every host entry in the NIS host table, you must have a corresponding host entry in DNS. multiple NIS domains in one mail domain -- All NIS host maps under a common mail domain should have the same set of host entries. For example, the host map in the ebs.admin.acme.com domain should be the same as the host map in the esg.admin.acme.com. Otherwise, one address might work in one NIS domain but fail in the other NIS domain. Configuration Issues with NIS+ and sendmailThis list includes all the configuration issues that you must resolve before using sendmail when using NIS+ as your only name service. mail domain name -- If you are setting up NIS+ as your primary name service, sendmail can look up the mail domain from the NIS+ sendmailvars table, a two-column NIS+ table with one key column and one value column. To set up your mail domain, you must add one entry to this table. This entry should have the key column set to the literal string maildomain and the value column set to the your mail domain name (for example, admin.acme.com). Although NIS+ allows any string in the sendmailvars table, the suffix rule still applies for the mail system to work correctly. You can use nistbladm to add the maildomail entry to the sendmailvars table. For example:
mailhost host name -- You must have a mailhost entry in the NIS+ hosts table. full host names -- NIS+ "understands" the full host name. Following the regular NIS+ setup procedure satisfies this requirement. matching full and short host names -- To satisfy this requirement, you can duplicate the entries in the host table, or you can enter all host entries in the user name service domains into a master host table at mail domain level. multiple NIS domains in one mail domain -- To satisfy this requirement, you can duplicate the entries in all the host tables, or you can type all host entries in the user name service domains into a master host table at mail domain level. Because you are merging (logical or physical) multiple host tables into one host table, the same host name cannot be reused in the multiple name service domain sharing a common mail domain. Configuration Issues with NIS+ and DNS while Using sendmailThis list includes all the configuration issues that you must resolve before using sendmail when using NIS+ with DNS as your name service. mail domain name -- If you are setting up NIS+ as your primary name service, sendmail can look up the mail domain from the NIS+ sendmailvars table, a two-column NIS+ table with one key column and one value column. To set up your mail domain, you must add one entry to this table. This entry should have the key column set to the literal string maildomain and the value column set to the your mail domain name (for example, admin.acme.com). Although NIS+ allows any string in the sendmailvars table, the suffix rule still applies for the mail system to work correctly. You can use nistbladm to add the maildomail entry to the sendmailvars table. For example:
Notice that this mail domain is a suffix of the NIS+ domain. mailhost host name -- If your network uses both NIS+ and DNS as the source for the host database, you can put the mailhost entry in either the NIS+ or DNS host table. Make sure that your users list NIS+ and DNS as the source for the host database in the /etc/nsswitch.conf file. full host names -- Both NIS+ and DNS "understand" full host names. Following the regular NIS+ and DNS setup procedures satisfies this requirement. matching full and short host names -- For every host entry in the NIS+ host table, you must have a corresponding host entry in DNS. multiple NIS domains in one mail domain -- To satisfy this requirement, you can duplicate the entries in all the host tables, or you can type all host entries in the user name service domains into a master host table at the mail domain level. Other Mail-Related TopicsThis section includes specific information about the various forms of alias files that can be used on a Solaris system. In addition, a discussion of .forward files is included. Mail Alias FilesYou can use any of the following files to maintain aliases. Which type of file to use depends on who will be using the alias and who needs to be able to change the alias. Each type of alias file has unique format requirements. Each of these is defined in the following sections. .mailrc AliasesAliases listed in a .mailrc file are accessible only by the user who owns the file. This allows users to establish an alias file they control and that is usable only by its owner. Aliases in a .mailrc file adhere to the following format:
where aliasname is the name the user will use when sending mail, and value is a valid email address. If a user establishes a personal alias for scott that does not match the email address for scott in the name space, mail will be routed to the wrong person when other people try to reply to mail generated by that user. The only workaround is to use any of the other aliasing mechanisms. /etc/mail/aliasesAny alias established in the /etc/mail/aliases file can be used by any user who knows the name of the alias and the host name of the system that contains the file. Distribution list formats in a local /etc/mail/aliases file adhere to the following format:
where aliasname is the name the user will use when sending mail to this alias and value is a valid email address. The aliases in the /etc/mail/aliases file are stored in text form. When you edit the /etc/mail/aliases file, run the newaliases program to recompile the database and make the aliases available in binary form to the sendmail program. Or you can use Administration Tool's Database Manager to administer the mail aliases stored in local /etc files. Normally, the root user only can edit this file. If using the Administration Tool, then all users in group 14, which is the sysadmin group, will be able to change the local file. Another option is to create an entry like:
where aliasname is the name the user will use when sending mail and /path/aliasfile is the full path to the file that includes the alias list. The alias file should include email entries, one entry on each line, and no other notations:
You can define additional mail files in /etc/mail/aliases to keep a log or a backup copy. The following entry stores all mail sent to aliasname in filename.
You can also route the mail to another process. The following stores a copy of the mail message in filename and prints a copy.
NIS Aliases MapAll users in the local domain can use entries included in the NIS aliases map. The sendmail program can use the NIS aliases map instead of the local /etc/mail/aliases files to determine mailing addresses. See the nsswitch.conf(4) man page for more information. Aliases in the NIS aliases map adhere to the following format:
where aliasname is the name the user will use when sending mail and value is a valid email address. The NIS aliases map should contain entries for all mail clients. In general, only the root user on the NIS master can change these entries. This type of alias might not be a good choice for aliases that are constantly changing, but can be useful if the alias points to another alias file; as in this syntax example:
where aliasname is the name the user will use when sending mail and host is the host name for the server that contains an /etc/mail/alias file. NIS+ mail_aliases TableThe NIS+ mail_aliases table contains the names by which a system or person is known in the local domain. The sendmail program can use the NIS+ mail_aliases table instead of the local /etc/mail/aliases files to determine mailing addresses. See the aliasadm(1M) and nsswitch.conf(4) man pages for more information. Aliases in the NIS+ mail_aliases table adhere to the following format:
Table 3-5 describes the four columns. Table 3-5 Columns in the NIS+ mail_aliases Table
The NIS+ mail_aliases table should contain entries for all mail clients. You can list, create, modify, and delete entries in the NIS+ aliases table with the aliasadm command. Or you can use Administration Tool's Database Manager to administer NIS+ mail aliases. If you are creating a new NIS+ aliases table, you must initialize the table before you create the entries. If the table exists, no initialization is needed. See "To List Individual Entries in the NIS+ mail_aliases Table " for information about how to create a NIS+ mail_aliases table. To use the aliasadm command, you must be a member of the NIS+ group that owns the aliases table or the person who created the table. .forward FilesUsers can create a .forward file in their home directories that sendmail uses to temporarily redirect mail or send mail to a custom set of programs without consulting a system administrator. When troubleshooting mail problems, particularly problems with mail not being delivered to the expected address, always check the user's home directory for a .forward file. A common mistake users make is to put a .forward file in the home directory of host1 that forwards mail to user@host2. When the mail gets to host2, sendmail looks up user in the NIS or NIS+ aliases and sends the message back to user@host1, resulting in a loop, and more bounced mail. Note - The root and bin accounts should never have .forward files. Creating these files will create a large security hole. If necessary, forward mail using the aliases file instead. In order for a .forward file to be consulted during the delivery of mail, the file must be writable only by the owner of the file. This prevents other users from breaking security. In addition, the paths leading up to the home directory must be owned and writable by root only. In particular, if a .forward file is in /export/home/terry, then /export and /export/home must be owned and writable only by root. The actual home directory should be writable only by the user. Other restrictions on a .forward file are that the file cannot be a symbolic link and cannot have more than one hard link. In addition to the standard .forward file, a .forward.hostname file can be created to redirect mail sent to a specific host. For example, if a user's alias has changed from a sandy@phoenix.eng.acme.com to sandy@eng.acme.com, then it might be nice to place a .forward.phoenix file in the home directory for sandy.
This allows for the mail to be forwarded to the correct place while also notifying the sender of the alias change. Notice that since the vacation program allows only one message file, so this can be done for only one message at a time. However, if the message is not host-specific, one vacation message file can be used by .forward files for many hosts. Another extension to the forwarding mechanism is the .forward+detail file. The detail string can be any sequence of characters as long as no operator characters are used. The operator characters are .:%&!^[]+. Using a file like this can make it possible to determine if someone else is giving your email address away. For instance, if a user told someone to use the email address sandy+test1@eng.acme.com, the user would be able to identify any future mail that was delivered to this alias. By default, any mail sent to sandy+test1@eng.acme.com alias is checked against the alias and .forward+detail files. If there are no matches, then the mail falls back to delivery to sandy@eng.acme.com, but the user is able to see a change in the To: header in their mail. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||