We hope you find this tutorial helpful. In addition to guides like this one, we provide simple cloud infrastructure for developers. Learn more →

How To Install the Send-Only Mail Server "Exim" on Ubuntu 12.04

Posted Nov 12, 2013 156.1k views Email Ubuntu



Due to the popularity of Gmail, Google Apps, Outlook.com, Yahoo! Mail & a myriad of other providers, many cloud-server users mistakenly fail to install a mail server, initially. However, humans are not the only ones that send electronic mail. If fact, many Linux server applications also need to send email.

Message Transfer Agent (MTA)

A Message Transfer Agent, or Mail Transfer Agent, transfers electronic mail messages from one computer to another. An MTA implements both the client (sending) and server (receiving) portions of the Simple Mail Transfer Protocol (SMTP).

Another popular MTA is Postfix; however, users that do not require a full-fledged mail server prefer the Exim send-only mail server because it is lightweight. Thus, Exim is a good choice for WordPress installations or server-monitoring apps that need to send email notifications.


This guide assumes that you have already:

  • Set your droplet's hostname and Fully Qualified Domain Name (FQDN).

See Setting the Hostname & Fully Qualified Domain Name (FQDN) on Ubuntu 12.04;

  • Created the necessary DNS records.

See How to Set Up a Host Name with DigitalOcean;

  • Created an SPF record.

See How To use an SPF Record to Prevent Spoofing & Improve E-mail Reliability.

Update Current Software

First, you want to update the software packages already on your virtual server by executing:

sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get -y dist-upgrade && sudo apt-get -y autoremove


To install Exim and its dependencies, execute:

sudo apt-get -y install exim4

To configure Exim for your environment, execute:

sudo dpkg-reconfigure exim4-config

Configure everything according to your needs. If you ever need to modify any of your settings, simply re-run the configuration wizard.

Mail Server Configuration Type

The first configuration window you encounter will ask you to select the "mail server configuration type that best meets your needs." If not already highlighted, use the arrow keys on your keyboard to select internet site; mail is sent and received directly using SMTP:

Select the option for internet site

Next, tap the "Tab" key (to highlight <Ok>) and press "Enter".

Enter FQDN

The next configuration window will ask that you enter your system's fully qualified domain name (FQDN) in the mail name configuration screen. Type the command below, substituting hostname, yourdomain & tld with your own values:


Next, tap the "Tab" key (to highlight <Ok>) and press "Enter".

SMTP Listener

The ensuing configuration window will ask you to decide on which interfaces you would like Exim to "listen." Enter:

Note: DigitalOcean anticipates IPv6 support in the near future, at which time you may want to instruct Exim to listen on both; ::1.

Next, tap the "Tab" key (to highlight <Ok>) and press "Enter".

Mail Destinations

The configuration prompt that follows will ask that you enter all of the destinations for which Exim should accept mail. List your:

  • FQDN;
  • local hostname;
  • localhost.localdomain;
  • localhost

Enter mail destinations

Next, tap the "Tab" key (to highlight <Ok>) and press "Enter".

Relay Options

Advanced configurations beyond the scope of this article allow you to use Exim as a relay mail server. In the next screen, leave the "relay mail" field blank.

Tap the "Tab" key (to highlight <Ok>) and press "Enter".

The subsequent screen is a follow-up to the relay-mail-server option. Leave this window blank and tap the "Tab" key (to highlight <Ok>) and press "Enter".

DNS Queries

Select No when asked whether to keep DNS queries to a minimum.

Make sure that <No> is highlighted and press "Enter".

Delivery Method

In the window that follows, choose whichever mail delivery method you'd like for incoming mail; although the Maildir format can make handling individual, locally-delivered mail messages easier:

Choose the Maildir delivery method

Next, tap the "Tab" key (to highlight <Ok>) and press "Enter".

Configuration File

In the ensuing prompt, choose the (default) unsplit configuration file by selecting "No".

Make sure that <No> is highlighted and press "Enter".

Postmaster address

In the last configuration window, you'll be asked to specify postmaster mail recipients. Enter the command below, substituting "you", "yourdomain" & "tld" with your own values:

root you@yourdomain.tld

Note: Make sure that, in addition to root, you enter at least one external email address (choose one that you check frequently).

Test Your Mail Configuration

Send a test email to make sure everything is configured correctly by issuing the following command (substituting someone@somedomain.tld for a valid, external email address):

echo "This is a test." | mail -s Testing someone@somedomain.tld

Note: You may need check the recipient's SPAM folder, in the event that the SPF record is not configured correctly.

Additional Resources

As always, if you need help with the steps outlined in this How-To, look to the DigitalOcean Community for assistance by posing your question(s), below.

Submitted by: Pablo Carranza


Creative Commons License