ELS Howto: Remote Mail


Synopsis

This document describes how to set up SMTP, IMAP and POP3 services on an Elemental Linux Server (ELS) system for the purpose of sending and receiving mail over the network.


Prerequisites

The following items should be verified before attempting this document.

  1. You should have completed the steps outlined in the ELS Howto: Local Mail.
  2. You will also need access to another workstation on your network with a mail client installed.
  3. Be sure your server and remote workstation can ping each other using their DNS names.

Installation

You will need to install the Alpine package and its included IMAP and POP3 servers. The mail transfer agent, Exim is already installed as part of the base packages.

Here are the instructions to set up Alpine.

  1. Mount the ELS 'Extra Applications' CD-ROM on /media/cdrom.
  2. Extract the Alpine package into the root of the server's directory hierarchy.
  3. Create symbolic links for the Alpine package's binaries in the /opt/bin and /opt/sbin directories.

Example

The example below shows how you would install Alpine from the ELS CD-ROM.

mount /media/cdrom

cd /
tar -zxf /media/cdrom/extra/alpine-2.00.i586.tar.gz

cd /opt/bin
ln -s ../alpine-2.00/bin/* .
cd /opt/sbin
ln -s ../alpine-2.00/sbin/* .

Configuration

Provided you have already completed the ELS Howto: Local Mail, there are only a few configuration steps remaining. These are outlined below:

  1. Edit /etc/firewall to allow unrestricted access on ports 25, 110 and/or 143 for any hosts trying to use email.
  2. Edit /etc/inetd.conf and uncomment the lines for the pop3 and/or imap services.
  3. Send a HUP signal to inetd to force a re-read of its configuration file.
  4. Configure exim to start automatically at boot.

Example

The example below shows the changes to /etc/firewall and /etc/inetd.conf as well as the commands to configure automatic start-up of the exim daemon.

vi /etc/firewall

-A INPUT -p tcp -s 192.168.1.0/24 --dport 25 -j ACCEPT
-A INPUT -p tcp -s 192.168.1.0/24 --dport 110 -j ACCEPT
-A INPUT -p tcp -s 192.168.1.0/24 --dport 143 -j ACCEPT

vi /etc/inetd.conf

pop3   stream  tcp     nowait  root    /opt/sbin/ipop3d        ipop3d
imap   stream  tcp     nowait  root    /opt/sbin/imapd         imapd

killall -HUP inetd

chmod +x /etc/init.d/exim

Notes


Testing

Test the setup by attempting to send and receive mail from a remote machine.

  1. Manually start exim.
  2. Set up the remote mail client for the user account designated as postmaster on the ELS host.
  3. Enter the IP address of the ELS machine for the SMTP, POP3 and/or IMAP server addresses.
  4. Send an email to postmaster@host.domain.lan.
  5. Verify that the email is received.

Example

The following example shows a successful start of the exim daemon and the parameters needed for a mail client using IMAP to read mail. An example of settings required by the Mozilla Thunderbird new account setup wizard are also shown.

Server

login: root
password:

# /etc/init.d/exim start
Mail server is starting.

# exit

Client

Name: Joe
Email Address: joe@els.mynetwork.lan

Incoming Server Type: IMAP Mail Server
Incoming Server Name: els.mynetwork.lan

Incoming User Name: joe

Account Name: joe@els.mynetwork.lan

Outgoing Server Name: els.mynetwork.lan
Outgoing Server: els.mynetwork.lan

If mail delivery fails, here are some things to check.

  1. Be sure that both the server and the client have either a hosts file entry or a DNS server record for proper name resolution.
  2. Verify that exim is listening on port 25 using the command netstat -tln on the ELS machine.
  3. Verify that the ELS host's firewall is open on ports 25, 110 nd 143 by issuing the command iptables -L -n and that the same ports are open on the remote workstation.
  4. Look for a non-delivery report (NDR) returned to the mail client.
  5. Check the contents of /var/spool/exim/log/mailog.
  6. Check the contents of any files found in the /var/spool/exim/msglog directory.
  7. Try sending a message using the /usr/lib/sendmail method and verify that the message can be viewed through POP3 and/or IMAP.

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