Mail Administration Guide

Chapter 2 Setting Up and Administering Mail Services

This chapter describes how to set up and administer mail services.

If you are not familiar with administering mail services, read Chapter 1, Understanding Mail Services, for an introduction to the terminology and structure of the mail services and for descriptions of several mail service configurations.

Use the following table to find the page for specific task instructions.

Setting Up Mail Services

You can set up a mail service relatively easily if your site does not provide connections to electronic mail (email) services outside your company or if your company is in a single domain.

Chapter 3, Customizing sendmail Configuration Files, contains information about how to create more complicated configuration files.

Mail requires two types of configurations for local mail and two more for communication with networks outside of your domain. You can combine these configurations on the same system or provide them on separate systems. You need to set up systems on your site to perform the functions described in Table 2-1.

Table 2-1 Mail Configurations

Configuration 

Description 

Mail client

Mail clients are users who have mailboxes on a mail server. 

Mail server

The mail server stores mailboxes in the /var/mail directory.

Mail host

You need at least one mail host. The mail host resolves difficult email addresses and reroutes mail within your domain. 

Mail gateway

A mail gateway is a connection between different networks outside your domain or between differing communications networks. You must add rules to the sendmail.cf file to set up a gateway. See Chapter 3, Customizing sendmail Configuration Files, for information about adding rules. If you have to set up a mail gateway, you should find a gateway configuration file that is close to what you need and modify it to fit your situation.

Before you begin to set up your mail service, choose the systems to act as mail servers, mail hosts, and mail gateways. You should also make a list of all the mail clients for which you will be providing service and include the location of their mailboxes. This list will help you when you are ready to create mail aliases for your users. See Chapter 1, Understanding Mail Services, for more information about the function each of these systems provides. For your convenience, guidelines about which systems are good candidates for mail server, mail host, and mail gateways are repeated in the following sections.

To simplify the setup instructions, this chapter tells you what you need to do to set up individual mail servers, mail hosts, mail clients, and relay hosts. If a system in your mail services configuration is acting in more than one capacity, follow the appropriate instructions for each type of system. For example, if your mail host and mail server functions are on the same system, follow the directions for setting up that system as a mail host and then follow the directions for setting up the same system as a mail server.


Note -

The following procedures for setting up a mail server and mail client apply when mailboxes are NFS-mounted. However, mailboxes typically are maintained in locally mounted /var/mail directories--in which case the following procedures are not needed.


Setting Up Mail Security

By default, security permissions on a /var/mail directory allow read, write, and execute access to the owner, members of groups to which the owner belongs, and all others. On Solaris 2.x mail servers, you can make a /var/mail directory more secure by changing its default permissions to allow only read and write access to anyone outside the owner's groups, as long no SunOS 4.1.x mail clients are connected. For more information about changing directory permissions, see the System Administration Guide.

How to Set Up a Mail Server

There are no special steps required to set up a mail server that is only serving the mail for local users. The user must have an entry in the password file or in the name space, and the user should have a local home directory (so that ~/.forward can be checked) for mail to be delivered. This is why home directory servers are often set up as the mail server.

The mail server may route all mail for many mail clients. The only resource requirement for this type of mail server is that it have adequate spooling space for client mailboxes. The /var/mail directory must be made available for remote mounting.

For this task, check the /etc/dfs/dfstab file to be sure the /var directory is exported.

  1. Type share and press Return.

    If the /var directory is shared, you do not need to do more. If the /var directory is not exported, continue with the next step.

  2. Type share -F nfs /var/mail and press Return.

  3. To permanently share the file system, edit /etc/dfs/dfstab and add the command line used in step 2.


Note -

The mail.local program automatically creates mailboxes in the /var/mail directory the first time a message is delivered. You do not need to create individual mailboxes for your mail clients.


How to Set Up a Mail Client

A mail client is a user of mail services, with a mailbox on a mail server, and a mail alias in the /etc/mail/aliases file that points to the location of the mailbox.

  1. Become root on the mail client's system.

  2. Make sure that there is a /var/mail mount point on the mail client's system.

  3. Mount the /var/mail directory from the mail server.

    The mail directory may be automatically mounted or mounted at boot time.

    1. To mount /var/mail automatically, edit /etc/auto_direct and add an entry like this one:


      /var/mail -rw,hard,actimeo=0 server:/var/mail
    2. To mount /var/mail at boot time, edit the /etc/vfstab file and add an entry for the /var/mail directory on the mail server, mounting it on the local /var/mail directory.


      server:/var/mail - /var/mail nfs - no rw,hard,actimeo=0

      The client's mailbox will be automatically mounted any time the system is rebooted. Type mountall to mount the client mailbox until the system is rebooted.


      Caution - Caution -

      You must include the actimeo=0 option when mounting mail from an NFS server to allow mailbox locking and access to work properly.


  4. Use the Administration Tool to edit the /etc/hosts file and add an entry for the mail server.

    This step is not required if you are using a name service.

  5. Add an entry for the client to one of the alias files.

    See "Creating Mail Aliases" for information about how to create mail aliases for different kinds of mail configurations.


    Note -

    The mail.local program automatically creates mailboxes in the /var/mail directory the first time a message is delivered. You do not need to create individual mailboxes for your mail clients.


How to Set Up a Mail Host

A mail host resolves email addresses and reroutes mail within your domain. A good candidate for a mail host is a system that connects your systems to the outside world or to a parent domain.

  1. Become root on the mail host system.

  2. Use the Administration Tool to edit the /etc/hosts file.

    Add the word mailhost after the IP address and system name of the mail host system. The system is designated as a mail host.

  3. Create an entry for the new mail host in one of the hosts files.

    If you are using NIS or NIS+, add an entry including a host alias called mailhost to the host entry for the new mail host.

    If you are not using NIS or NIS+, you must create an entry in /etc/hosts for each system on the network. The entry should use this format: IP address mailhost_name mailhost

  4. Type cp /etc/mail/main.cf /etc/mail/sendmail.cf and press Return.

    This copies and renames the /etc/mail/main.cf file.

  5. Reboot the mail host and test your mail configuration.

    See "Testing the Mail Configuration" for information.

How to Set Up a Mail Gateway

A mail gateway manages communication with networks outside of your domain. The mailer on the sending mail gateway can match the mailer on the receiving system.

A good candidate for a mail gateway is a system attached to Ethernet and phone lines or a system configured as a router to the Internet. You might want to configure the mail host or another system as mail gateway. You might choose to configure more than one mail gateway for your domain. If you have UUCP connections, you should configure the system (or systems) with UUCP connections as the mail gateway.

  1. Become root on the mail gateway.

  2. Type cp /etc/mail/main.cf /etc/mail/sendmail.cf and press Return.

    This command copies and renames the main.cf file.

  3. Edit the /etc/mail/sendmail.cf file and make the following changes:

    1. Only if your relay mailer is not UUCP, change the default entry DMsmartuucp to the entry that is appropriate for your relay mailer.

      Available mailers are smartuucp (the default), ddn, ether, and uucp. If your relay mailer is UUCP, you do not need to change this entry.

      You can specify a different relay mailer for each mail gateway (if appropriate). You can define rule sets for other relay mailers in the main.cf file. See "Mailers" for a description of each of the default relay mailers.

    2. In the entry DR ddn-gateway, replace ddn-gateway with the name of your mail relay.

      The DR entry defines the mail relay.

    3. In the entry CR ddn-gateway, replace ddn-gateway with the name of your mail relay.

      The CR entry defines the class of the mail relay. You can designate one or more hosts as a member of this class.

    4. (Optional) Add a Dmmaildomain or Lmmaildomain entry to define the mail domain name to be used for mail delivery.

      The m macro defines the mail domain name. If the macro is not defined, the naming service domain name is used with the first component stripped off. For example, ecd.east.acme.com becomes east.acme.com. If you use the L command, sendmail looks up the name to use in the sendmailvars table, using maildomain as the search key.

    5. Save the edits.

  4. Reboot the mail gateway and test your mail configuration.

    See "Testing the Mail Configuration" for information.

Creating Mail Aliases

You can use the aliasadm command to create mail aliases for a user. Mail aliases must be unique within the domain. This section tells you how to use command lines to search the mail aliases table for aliases, and to create mail aliases for NIS+, NIS, DNS, or on the local system.

Or you can use the Administration Tool's Database Manager application to perform these tasks on the aliases database.

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 will be defined in the following sections.

Mail Alias Files

You can use any of the following files to maintain aliases. A combination of these files are used in many sites.

.mailrc Aliases

Aliases 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:


alias aliasname value value value ...

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/aliases

Any 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:


aliasname: value,value,value...

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:


aliasname: :include:/path/aliasfile

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:


user1@host1
user2@host2

You can change the permissions on this file so that multiple users can alter the alias, without supplying root access or permissions to change data with the Administration Tool.

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.


aliasname: /home/backup/filename

Note -

All mail files must be writable by daemon. To allow other users to deliver mail to this file, set the permissions so that the file is owned by a specific user, the group owner is daemon, and the file permissions are at least 0620.


You can also route the mail to another process. The following stores a copy of the mail message in filename and prints a copy.


aliasname: "|tee -a /home/backup/filename |lp"

NIS Aliases Map

All 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:


aliasname: value,value,value...

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:


aliasname: aliasname@host

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 Table

The 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:


alias:			expansion					[options		# "comments"]

Table 2-2 describes the four columns.

Table 2-2 Columns in the NIS+ mail_aliases Table

Column 

Description 

alias

The name of the alias 

expansion

The value of the alias or a list of aliases as it would appear in a sendmail /etc/mail/aliases file

options

Reserved for future use 

comments

Comments about an individual alias 

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.

How to List the Contents of an NIS+ Aliases Table

To use the aliasadm command, you must be either root, a member of the NIS+ group that owns the mail_aliases table, or the person who created the table.

To List the Entire Contents of the NIS+ mail_aliases Table

    Type aliasadm -l and press Return.

This lists the contents of the aliases table in alphabetical order by alias.


Note -

If you have a large aliases table, listing the entire contents can take some time. If you are searching for a specific entry, pipe the output through the grep command (aliasadm -l | grep entry) so that you can use the grep search capability to find specific entries.


To List Individual Entries in the NIS+ mail_aliases Table

    Type aliasadm -m alias and press Return.

The alias entry is listed.


# aliasadm -m ignatz
ignatz: ignatz@saturn # Alias for Iggy Ignatz

Note -

The aliasadm -m option matches only the complete alias name. It does not match partial strings. You cannot use metacharacters (like * and ?) with the aliasadm -m option. If you are interested in partial matches, type aliasadm -l | grep partial-string and press Return.


How to Add Aliases to a NIS+ mail_aliases Table From the Command Line

If you are creating a completely new NIS+ mail_aliases table, you first must initiate the NIS+ table.

To Initiate a NIS+ Table

    Type aliasadm -I and press Return.

To Add Aliases to a NIS+ mail_aliases Table From the Command Line

  1. Compile a list of each of your mail clients, the locations of their mailboxes, and the names of the mail server systems.

  2. Become root on any system.

  3. For each alias, type aliasadm -a alias expanded_alias [options comments] and press Return.

    This adds the aliases to the NIS+ aliases table.


    # aliasadm -a iggy iggy.ignatz@saturn "Iggy Ignatz"
  4. Type aliasadm -m alias and press Return.

    This displays the entry you created.

  5. Check that the entry is correct.

How to Add Entries by Editing a NIS+ mail_aliases Table

If you are adding more than two or three aliases, you might want to edit the NIS+ table directly.

  1. Compile a list of each of your mail clients, the locations of their mailboxes, and the names of the mail server systems.

  2. Become root on any system.

  3. Type aliasadm -e and press Return.

    The aliases table is displayed using the editor set with the $EDITOR environment variable. If the variable is not set, the vi editor is used.

  4. Type each alias on a separate line, using these formats:

    1. Type the aliases in any order, at any place in the table.

      The order is not important to the NIS+ mail_aliases table. The aliasadm -l command sorts the list and displays them in alphabetical order.

    2. Use the format alias: expanded_alias # ["option"# "comments"]

      If you leave the option column blank, type an empty pair of quotation marks ("") and then add the comments.

    3. End each line by pressing Return.

  5. Check that the entries are correct.

  6. Save the changes.

How to Change Entries in a NIS+ mail_aliases Table

  1. Become root on any system.

  2. Type aliasadm -m alias and press Return.

    The information for the alias is displayed.

  3. Type aliasadm -c alias expanded_alias [options comments] and press Return.

    The alias is changed using the new information you provide.

  4. Type aliasadm -m alias and press Return.

    The entry you created is displayed.

  5. Check that the entry is correct.

How to Delete Entries From a NIS+ mail_aliases Table

  1. Become root on any system.

  2. Type aliasadm -d alias and press Return.

    The alias is deleted from the NIS+ mail_aliases table.

Setting Up NIS mail.aliases Map

The /etc/mail/aliases file on a NIS master contains all names by which a system or person is known. The NIS master is searched if there is no match in the local /etc/mail/aliases files. The sendmail program uses the NIS master file to determine mailing addresses. See the aliases(4) man page.

You can either edit the file on each system or edit the file on one system and copy it to each of the other systems.

Aliases are in the following form:


name: name1, name2, ...

You can use aliases for local names or domains. For example, an alias entry for user fred who has a mailbox on the system saturn and who is in the domain planets would have this entry in the /etc/mail/aliases file:


fred: fred@planets

How to Set Up NIS mail.aliases Map

  1. Compile a list of each of your mail clients, the locations of their mailboxes, and the names of the mail server systems.

  2. Become root on the NIS master server.

  3. Edit the /etc/mail/aliases file, and make the following entries:

    1. Add an entry for each mail client.

    2. Change the entry Postmaster: root to the mail address of the person who is designated as postmaster.

      See "Setting Up the Postmaster Alias" for more information.

    3. If you have created a mailbox for administration of a mail server, create an entry for root:mailbox@mailserver.

    4. Save the changes.

  4. Edit the /etc/hosts file on the NIS master server and create an entry for each mail server.

  5. Type cd /var/yp and press Return.

  6. Type make and press Return.

    The changes in the /etc/hosts and /etc/mail/aliases files are propagated to NIS slave systems. It takes a few minutes, at most, for the aliases to take effect.

Setting Up Local Mail Aliases Files

The /etc/mail/aliases file on a local system contains all names by which a system or person is known. The sendmail program uses this file to determine mailing addresses. See the aliases(4) man page.

If your network is not running a name service, the /etc/mail/aliases file of each system should contain entries for all mail clients. You can either edit the file on each system or edit the file on one system and copy it to each of the other systems.

Aliases are of the form:


name: name1, name2, ...

You can create aliases for only local names--a current host name or no host name. For example, an alias entry for user ignatz who has a mailbox on the system saturn would have this entry in the /etc/mail/aliases file:


ignatz: ignatz@saturn

It is a good idea to create an administrative account for each mail server. You do this by assigning root a mailbox on the mail server and adding an entry to the /etc/mail/aliases file for root. For example, if the system saturn is a mailbox server, add the entry root: sysadmin@saturn to the /etc/mail/aliases file.

How to Set Up Local Mail Aliases Files

  1. Compile a list of each of your mail clients and the locations of their mailboxes.

  2. Become root on the mail server.

  3. Edit the /etc/mail/aliases file and make the following entries:

    1. Add an entry for each mail client.

    2. Change the entry Postmaster: root to the mail address of the person who is designated as postmaster.

      See "Setting Up the Postmaster Alias" for more information.

    3. If you have created a mailbox for administration of a mail server, create an entry for root: mailbox@mailserver.

    4. Save the changes.

  4. Type newaliases and press Return.

    This creates an alias file in binary form that sendmail can use. The file is stored in the /etc/mail/aliases.dir and /etc/mail/aliases.pag files.

  5. Copy the /etc/mail/aliases, the /etc/mail/aliases.dir, and /etc/mail/aliases.pag files to each of the other systems.

    When you copy all three files you do not need to run the newaliases command on each of the other systems.

    You can copy the files by using the rcp or rdist commands or by using a script that you create for this purpose. Remember that you must update all the /etc/mail/aliases files each time you add or remove a mail client.

Setting Up DNS Aliases Files

The DNS name service does not support aliases for individuals. It does support aliases for hosts or domains using mail exchange (MX) records and cname records. You can specify host names, domain names, or both in the DNS database. See the Solaris Naming Setup and Configuration Guide for more information about administering DNS.

How to Use DNS With sendmail

  1. Edit the /etc/nsswitch.conf file and make sure that the hosts entry includes the dns flag.

    The host entry must include the dns flag for the DNS host aliases to be used.

  2. Check for a mailhost entry.

    Make sure there is an entry for mailhost in the DNS database.

Setting Up the Postmaster Alias

Every system should be able to send mail to a postmaster mailbox. You can create a NIS or NIS+ alias for postmaster or create one in each local /etc/mail/aliases file. Here is the default /etc/mail/aliases entry:


# Following alias is required by the mail protocol, RFC 822
# Set it to the address of a HUMAN who deals with this system's
# mail problems.
Postmaster: root

To create the postmaster alias, edit each system's /etc/mail/aliases file and change root to the mail address of the person who will act as postmaster.

You might want to create a separate mailbox for the postmaster to keep postmaster mail separate from personal mail. If you create a separate mailbox, use the mailbox address instead of the postmaster's mail address when you edit the /etc/mail/aliases files.

How to Create a Separate Mailbox for postmaster

  1. Create a user account for the person designated as postmaster and put an asterisk (*) in the password field.

  2. Once mail has been delivered, type mail -f postmaster and press Return.

    The mail program will be able to read and write to the mailbox name.

How to Add the postmaster Mailbox to the Aliases

  1. Become root and edit the /etc/mail/aliases file on each system.

    If your network does not run NIS or NIS+, edit the /etc/mail/aliases file.

  2. Change the postmaster alias from root to Postmaster: postmastermailbox@postmasterhost and save the changes.

  3. On the postmaster's local system create an entry in the /etc/mail/aliases file that defines the name of the alias (sysadmin, for example) and includes the path to the local mailbox.

  4. Type newaliases and press Return.

    Or you could change the Postmaster: entry in the aliases file to a Postmaster: /usr/somewhere/somefile entry.

Testing the Mail Configuration

When you have set up all the systems in your mail configuration, use the suggestions in this section to test the setup to be sure mail messages can be sent and received.

How to Test the Mail Configuration

  1. Reboot any system for which you have changed a configuration file.

  2. Send test messages from each system by typing /usr/lib/sendmail -v names </dev/null and press Return.

    Specify a recipient's email address in place of the names variable.

    This command sends a null message to the specified recipient and displays messages while it runs.

  3. Run these tests:

    1. Send mail to yourself or other people on the local system by addressing the message to a regular user name.

    2. If you are on Ethernet, send mail to someone on another system.

      Do this in three directions: from the main system to a client system, from a client system to the main system, and from a client system to another client system.

    3. If you have a mail gateway, send mail to another domain from the mail host to ensure that the relay mailer and host are configured properly.

    4. If you have set up a UUCP connection on your phone line to another host, send mail to someone at that host and have that person send mail back or call you when the message is received.

    5. Ask someone to send mail to you over the UUCP connection.

      The sendmail program cannot tell whether the message gets through, because it hands the message to UUCP for delivery.

    6. Send a message to postmaster on different systems and make sure that it comes to your postmaster's mailbox.

Administering the Mail Configuration

This section describes how to keep the mail service running smoothly.

Postmaster Duties

As postmaster your responsibilities for administering mail include the following tasks:

Mail Queue

Under high-load or temporary-failure conditions, sendmail puts a message into a job queue instead of delivering it immediately. The mail queue usually is processed automatically, but sometimes you might have to intervene. For example, if a major host is down for a period of time, the queue could become clogged. Although sendmail ought to recover gracefully when the host restarts, you could find performance unacceptably bad in the meantime.

Queue File Format

The sendmail program stores temporary queue files in the queue file /var/spool/mqueue. All such queue files have the form xfAA99999, where AA99999 is the ID for the file and x is the type. Table 2-3 shows the types of queue files.

Table 2-3 Types of Queue Files

Type 

Description 

d

Data file. The message body (excluding the header) is kept in this file. 

q

Queue control file. This file contains the information needed to process the job. 

t

A temporary file. This file is an image of the qf file when it is being rebuilt. When the rebuild is complete, the file is renamed qf.

x

Transcript file that shows everything that happens during that session. 

A qf file contains a series of lines, each beginning with a code letter. Not all lines are included with each message, but a complete list is shown in Table 2-4.

Table 2-4 Codes for the qf File

Code 

Description 

$

A macro definition. The values of certain macros (currently $r and $s) are passed through to the queue run phase.

B

The body type. This line defines the body type. Legal values are 7BIT and 8BITMIME. 

C

The controlling address. The syntax is localuser:aliasname. Recipient addresses following this line will be flagged so that deliveries will be run as the localuser (a user name from the password file or database); aliasname is the name of the alias that expanded to this address (for printing messages).

D

The name of the data file. There might only be one of these lines. 

E

The error recipient name. Error messages are sent to this user instead of the sender. This line is optional. 

F

Flag bits. This can be r, indicating that this is a response message and w, indicating that a warning message has been sent announcing that the mail has been delayed.

H

A header definition. There might be any number of these lines. The order is important: it represents the order in the final message. The syntax is the same as header definitions in the configuration file. 

L

Information to compute the content length. 

M

A message line, which is printed by using sendmail with the -bp flag and is generally used to store status information. It can contain any text.

P

The current message priority, which is used to order the queue. The higher the number, the lower the priority. The priority increases as the message stays in the queue. The initial priority depends on the message class and the size of the message. 

R

A recipient name. There is one line for each recipient. The recipient name is normally completely aliased, but its aliases are redone when the job is processed. The recipient name must be at the end of the qf file.

S

The sender name. There might be only one of these lines. 

T

The job creation or submission time in seconds, which is used to compute when the job times out. 

See Chapter 3, Customizing sendmail Configuration Files for more information.

The queue is automatically run at the interval specified in the sendmail.cf file (the default is every hour). The queue is read and sorted, and then sendmail tries to process all jobs in order. The sendmail program first checks to see if a job is locked. If the job is locked, sendmail ignores the job; if the job is not locked, sendmail processes it.

If a major host goes down for several days, the queue may become prohibitively large and sendmail will spend time sorting the queue. You can fix this by moving the queue to a temporary place and creating a new queue. You can run the old queue later when the host is returned to service.

How to Print the Queue

You can print the contents of the queue with mailq.This command is equivalent to specifying the -bp flag to sendmail.

    Type /usr/bin/mailq | more and press Return.

A list of the queue IDs, the size of the message, the date the message entered the queue, the message status, and the sender and recipients are displayed.

How to Force the Queue

    Type /usr/lib/sendmail -q -v and press Return.

This forces the processing of the queue and displays progress of the jobs as the queue is cleared.

How to Run a Subset of the Mail Queue

    Type /usr/lib/sendmail -qRstring and press Return.

You can run a subset of the queue at any time with the -qRstring (run queue where any recipient name matches string) or with -qInnnn (run just one message with queue ID nnnnn).

This example processes everything in the queue for recipient wnj.


# /usr/lib/sendmail -qRwnj

How to Move the Queue

  1. Become root on the mail host.

  2. Type /etc/init.d/sendmail stop and press Return.

    This kills the old sendmail daemon to keep it from trying to process the old queue directory.

  3. Type cd /var/spool and press Return.

  4. Type mv mqueue omqueue; mkdir mqueue and press Return.

    This moves the directory, mqueue, and all its contents to the omqueue directory and then creates a new empty Rmqueue directory.

  5. Type chmod 755 mqueue; chown daemon.daemon mqueue; and press Return.

    These commands set the permissions of the directory to read/write/execute by owner, and read/execute by group and others; these commands also set the owner and group to daemon.

  6. Type /etc/init.d/sendmail start and press Return.

    This starts a new sendmail daemon.

How to Run the Old Mail Queue

  1. Type /usr/lib/sendmail -oQ/var/spool/omqueue -q and press Return.

    The -oQ flag specifies an alternate queue directory and the -q flag says to run every job in the queue. Use the -v flag if you want to see the verbose output displayed on the screen.

  2. When the queue is finally emptied type rmdir /var/spool/omqueue and press Return.

    This removes the empty directory.

System Log

The mail services log most errors using the syslogd program. The default is for syslogd to send messages to the loghost.

You can define a system called loghost in the /etc/hosts file to hold all logs for an entire NIS domain. The system log is supported by the syslogd program. You specify a loghost in /etc/hosts. If no loghost is specified, then error messages from syslogd are not reported.

Example 2-1 shows the default /etc/syslog.conf file:


Example 2-1 Default /etc/syslog.conf File


#ident "@(#)syslog.conf   1.3        93/12/09 SMI"  /* SunOS 5.0 */  #
# Copyright (c) 1994 by Sun Microsystems, Inc. 
#
# syslog configuration file. 
# 
# This file is processed by m4 so be careful to quote (`') names 
# that match m4 reserved words. Also, within ifdef's, arguments 
# containing commas must be quoted. 
# 
# Note: Have to exclude user from most lines so that user.alert 
#       and user.emerg are not included, because old sendmails 
#       have no 4.2BSD based systems doing network logging, you 
#       can remove all the special cases for "user" logging.
# *.err;kern.debug;auth.notice;user.none	        /dev/console 
*.err;kern.debug;daemon,auth.notice;mail.crit;user.none /var/adm/messages 
*.alert;kern.err;daemon.err;user.none            operator 
*.alert;user.none	                                root 
*.emerg;user.none	                                * 
# if a non-loghost machine chooses to have authentication messages 
# sent to the loghost machine, un-comment out the following line:
#auth.notice         ifdef(`LOGHOST', /var/log/authlog, @loghost) 
mail.debug           ifdef(`LOGHOST', /var/log/syslog, @loghost) 
# 
# non-loghost machines will use the following lines to cause "user" 
# log messages to be logged locally. 
# 
ifdef(`LOGHOST', , 
user.err             /dev/console 
user.err             /var/adm/messages 
user.alert           `root, operator' 
user.emerg           * 
)

You can change the default configuration by editing the /etc/syslog.conf file. You must restart the syslog daemon for any changes to take effect. You can add these selections to the file to gather information about mail:

The following entry sends a copy of all critical, informational and debug messages to /var/log/syslog.


mail.crit;mail.info;mail.debug			/var/log/syslog

Each line in the system log contains a time stamp, the name of the system that generated it, and a message. The syslog file can log a large amount of information.

The log is arranged as a succession of levels. At the lowest level, only unusual occurrences are logged. At the highest level, even the most mundane and uninteresting events are recorded. As a convention, log levels under 10 are considered "useful." Log levels higher than 10 are usually used for debugging. See the System Administration Guide for information about loghost and the syslogd program.

Troubleshooting Tips

This section provides some tips and tools that you can use for troubleshooting problems with the mail services.

How to Check Aliases

To verify aliases and whether mail can be delivered to a given recipient:

    Type /usr/lib/sendmail -v -bv recipient and press Return.

The command displays the aliases and identifies the final address as deliverable or not.

Here is an example of the output:


% /usr/lib/sendmail -v -bv shamira@raks
shamira... aliased to   mwong
mwong... aliased to              shamira@raks
shamira@raks... deliverable
%

You should take extra care to avoid loops and inconsistent databases when both local and domain-wide aliases are used. Be especially careful when you move a user from one system to another to avoid creating alias loops.

How to Test the sendmail Rule Sets

  1. Type /usr/lib/sendmail -bt and press Return.

    Information is displayed.

  2. At the last prompt (>) type a 3,0 (zero) and the mail address you want to test.

  3. Type Control-d to end the session.

Here is an example of the output:


% /usr/lib/sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> 3,0 shimara@raks
rewrite: ruleset  3   input: shimara @ raks
rewrite: ruleset  6   input: shimara <@ raks>
rewrite: ruleset  6 returns: shimara <@ raks>
rewrite: ruleset  3 returns: shimara <@ raks>
rewrite: ruleset  0   input: shimara <@ raks>
rewrite: ruleset  9   input: shimara <@ raks>
rewrite: ruleset  9 returns: shimara <@ raks>
rewrite: ruleset  0 returns: $# ether $# mailhost $: shimara < @ raks >
>

See Chapter 3, Customizing sendmail Configuration Files, for a complete description of the diagnostic information.

How to Verify Connections to Other Systems

To verify connections to other systems, you can use the mconnect program to open connections to other sendmail systems over the network. The mconnect program runs interactively. You can issue various diagnostic commands. See the mconnect(1) man page for a complete description. The following example verifies that mail to the user name shamira is deliverable.


$ mconnect raks
connecting to host raks (129.144.52.96), port 25
connection open
220 raks.Eng.Sun.COM Sendmail SMI-8.6/SMI-SVR4 ready at Tue, 25 Jul 1995 10:45:28 -0700
vrfy shamira
250 Michael Wong <shamira@raks.Eng.Sun.COM>
>

If you cannot use mconnect to connect to an SMTP port, check these conditions:

Other Diagnostic Information

For other diagnostic information, check the following sources: