ELS Howto: Local Mail


Synopsis

This document outlines the process of setting up mail delivery to and from users of an Elemental Linux Server (ELS) system. Delivery of mail to other systems on the network is not covered here. For more information on that topic, see the ELS Howto: Remote Mail when you have completed this document.


Prerequisites

You should have at least one non-root user set up on the system prior to beginning this document.


Installation

The mail delivery agent, Exim, and the basic mail client, mailx, are already installed as part of the base packages. You may also want to install Alpine as a mail client, but it is not required. Instructions for setting up alpine are included in the ELS Howto: Remote Mail.


Configuration

There are three configuration files needed for local mail delivery. Two are used by Exim and one is for mailx. Even if you intend to use Alpine exclusively it is still a good idea to configure mailx.

  1. Copy the aliases file from the /usr/share/doc/exim directory into the /etc directory and unzip it.
  2. Edit /etc/aliases and make the following changes.
  3. Copy the exim.conf file from the /usr/share/doc/exim directory into the /etc/exim directory and unzip it.
  4. Copy the mailx.rc file from the /usr/share/doc/mailx directory into the /etc directory and unzip it.

Example

The example below shows the /etc/aliases file with the postmaster address set to a local user named joe. Any unchanged lines have been removed for brevity.

postmaster: joe@localhost.lan
mailer-daemon: postmaster
root: postmaster

The commands that follow show how you would copy exim.conf and mailx.rc, decompressing them on the fly.

zcat /usr/share/doc/exim/aliases > /etc/aliases
zcat /usr/share/doc/exim/exim.conf > /etc/exim/exim.conf
zcat /usr/share/doc/mailx/mailx.rc > /etc/mailx.rc

Testing

You can test the setup by sending email to various users on the system. Detailed steps are below.

  1. Login as the non-root user you designated as postmaster in /etc/aliases.
  2. Start a message to the root user with the command /usr/lib/sendmail root
  3. Type a sentence or two and terminate the message by pressing CTRL-D (a.k.a. End-Of-File).
  4. Use the mailx or alpine mail client to verify that you received an email containing the message you sent in the previous step.
  5. Repeat the process for postmaster, mailer-daemon and any other aliases you enabled in /etc/aliases.

Here is an example of a successful test:

login: joe
password:

$ /usr/lib/sendmail root
Subject: Hello

Hello World!
<CTRL-D>

$ mailx
Heirloom mailx version 12.3 01/07/07.  Type ? for help.
"/var/spool/mail/joe": 1 message 1 new
>N  1 joe@host.domain.lan  Tue Aug 26 21:04   14/503   Hello
? 1
Message  1:
From joe@host.domain.lan  Tue Aug 26 21:04:03 2008
X-Original-To: joe
Delivered-To: joe@host.domain.lan
Subject: Hello
Date: Tue, 26 Aug 2008 21:03:48 -0500 (CDT)
From: joe@host.domain.lan (Joe)
To: undisclosed-recipients:;

Hello World!

? q
Held 1 message in /var/spool/mail/joe

If your test was not successful, here are some troubleshooting tips.

  1. Check the contents of /var/spool/exim/log/mailog.
  2. Check the contents of any files found in the /var/spool/exim/msglog directory.

You can find more information about configuring and troubleshooting Exim at http://www.exim.org/docs.html