Mail Administration Guide

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.

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. 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 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 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.


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 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 can 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 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. 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. Verify the hostname configuration.

    Run the check-hostname script to verify if sendmail will be able to identify the fully qualified hostname 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 hostname, you need to add the fully qualified hostname as the first alias for the host in /etc/hosts.

  3. Use the Administration Tool 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 subdomainname in the output of this command: /usr/lib/sendmail -bt -d0 </dev/null.


    % /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
    ========================================================
  4. 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 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. Type cp /etc/mail/main.cf /etc/mail/sendmail.cf and press Return.

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

  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 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. Verify the hostname configuration.

    Run the check-hostname script to verify if sendmail will be able to identify the fully qualified hostname 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 hostname, you need to add the fully qualified hostname 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.