System Administration Guide, Volume 3

Setting Up Mail Services

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

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:

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 are 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 33, Introduction to 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.


How to Set Up a Mail Server

No special steps are required to set up a mail server that is only serving 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 can 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 that /etc/dfs/dfstab file shows the /var/mail directory is exported.

  1. Become superuser on the mail server.

  2. Check that the /var/mail directory is available for remote access.

    Type share and press Return. If the /var/mail directory is listed, you do not need to do more. If the /var/mail directory is not listed, continue with the next step.

  3. Make the /var/mail directory available for remote access.

    Type the following command:


    # share -F nfs /var/mail
    
  4. Make the file system permanently available for remote access.

    Edit /etc/dfs/dfstab and add the command line used in step 2.


    # cat /etc/dfs/dfstab
     ..
    share -F nfs -o rw /var/mail

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 superuser on the mail client's system.

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

    Using ls tells you if the file system exists. The following example shows the response if the file system has not been created.


    # ls -l /var/mail
    /var/mail not found

    If mail files are in this directory, you should probably move them, so that they are not covered when the /var/mail directory is mounted from the server.

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

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

    1. (Optional) 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. (Optional) 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 is 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. Update/etc/hosts.

    Use admintool 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 "Administering Mail Alias Files" 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.


  6. Restart sendmail.

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 superuser on the mail host system.

  2. Verify the host name configuration.

    Run the check-hostname script to verify if sendmail will be able to identify the fully qualified host name for this server:


    % /usr/lib/mail/sh/check-hostname
    hostname phoenix OK: fully qualified as phoenix.eng.acme.com

    If this script is not successful in identifying the fully qualified host name, you need to add the fully qualified hos tname as the first alias for the host in /etc/hosts.

  3. Update/etc/hosts.

    Use admintool to edit the /etc/hosts file. Add the word mailhost and mailhost.domainname after the IP address and system name of the mail host system. The system is designated as a mail host. The domainname should be identical to the string given as the subdomain name in the output of the following command:


    % /usr/lib/sendmail -bt -d0 </dev/null
    Version 8.9.0+Sun
     Compiled with: MAP_REGEX LOG MATCHGECOS MIME7TO8 MIME8TO7 NAMED_BIND 
                    NDBM NETINET NETUNIX NEWDB NIS NISPLUS QUEUE SCANF SMTP
                    USERDB XDEBUG
    
    ============ SYSTEM IDENTITY (after readcf) ============
          (short domain name) $w = phoenix
      (canonical domain name) $j = phoenix.eng.acme.com
             (subdomain name) $m = eng.acme.com
                  (node name) $k = phoenix
    ========================================================

    Here is an example of how the hosts file should look after these changes:


    # cat /etc/hosts
    #
    # Internet host table
    #
    127.0.0.1       localhost        
    129.0.0.1       phoenix mailhost mailhost.eng.acme.com        loghost
  4. Create an entry for the new mail host in the appropriate hosts file.

    If you are using NIS or NIS+, add an entry including a host alias called mailhost and mailhost.domainname 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 mailhost.domainname

  5. Change the correct configuration file.

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


    # cp /etc/mail/main.cf /etc/mail/sendmail.cf
    
  6. Restart sendmail and test your mail configuration.

    See "How to Test 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 superuser on the mail gateway.

  2. Change the configuration file.

    The following command copies and renames the main.cf file.


    # cp /etc/mail/main.cf /etc/mail/sendmail.cf
    
  3. Verify the host name configuration.

    Run the check-hostname script to verify if sendmail will be able to identify the fully qualified host name for this server:


    # /usr/lib/mail/sh/check-hostname
    hostname phoenix OK: fully qualified as phoenix.eng.acme.com

    If this script is not successful in identifying the fully qualified hos tname, you need to add the fully qualified host name as the first alias for the host in /etc/hosts.

  4. Restart sendmail and test your mail configuration.

    See "How to Test the Mail Configuration" for information.

How to Use DNS With sendmail

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.

  1. Become superuser.

  2. Enable DNS host lookups (NIS+ only).

    Edit the /etc/nsswitch.conf file and remove the # from the hosts definition that includes the dns flag. The host entry must include the dns flag, as shown below, for the DNS host aliases to be used.


    # grep hosts /etc/nsswitch.conf
    #hosts:      nisplus [NOTFOUND=return] files
    hosts:      nisplus dns [NOTFOUND=return] files
  3. Check for a mailhost and mailhost.domainname entry.

    Make sure an entry exists for mailhost and mailhost.domainname in the DNS database.