// Tutorial //

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

Published on November 12, 2013
Default avatar
By Pablo Carranza
Developer and author at DigitalOcean.
How To Install the Send-Only Mail Server "Exim" on Ubuntu 12.04

Status: Deprecated

This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:

Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.

See Instead: This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.

Introduction


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.

Prerequisites


This guide assumes that you have already:

  • Set your droplet’s hostname and Fully Qualified Domain Name (FQDN).<br/>

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

  • Created the necessary DNS records.<br/>

See How to Set Up a Host Name with DigitalOcean;

  • Created an SPF record.<br/>

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

Installation


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 <code><Ok></code>) 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:

hostname.yourdomain.tld

Next, tap the “Tab” key (to highlight <code><Ok></code>) and press “Enter”.

SMTP Listener


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

127.0.0.1

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

Next, tap the “Tab” key (to highlight <code><Ok></code>) 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;
  • <code>localhost.localdomain</code>;
  • <code>localhost</code>

Enter mail destinations

Next, tap the “Tab” key (to highlight <code><Ok></code>) 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 <code><Ok></code>) 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 <code><Ok></code>) and press “Enter”.

DNS Queries


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

Make sure that <code><No></code> 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 <code><Ok></code>) and press “Enter”.

Configuration File


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

Make sure that <code><No></code> 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.

<div class=“author”>Submitted by: <a href=“https://plus.google.com/107285164064863645881?rel=author” target=“_blank”>Pablo Carranza</div>

If you’ve enjoyed this tutorial and our broader community, consider checking out our DigitalOcean products which can also help you achieve your development goals.

Learn more here


About the authors
Default avatar
Developer and author at DigitalOcean.

Still looking for an answer?

Was this helpful?
10 Comments

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

I’ve spent a whole day trying to figure out why I wasn’t able to send any email when all the settings were correct then I looked at the log I found that connections were timed out. Guess what? Digital Ocean is blocking it and you’ll have to ask them to free it. You won’t find this information nowhere, they aren’t even showing a prompt message when you setup you MTA. I’m really pissed about the time DO made me spend. Hope other can read this comment before going nuts.

The tutorial works fine if you have only one domain, but how to proceed when you have multiple virtual domains?

Could you check the contents of exim’s logs after trying to send an email on the command line: <pre> tail /var/log/exim4/mainlog </pre> The configuration file is at: <pre> /etc/exim4/exim4.conf.template </pre> but I don’t see why missing Postmaster address would cause you not to be able to send mail at all.

Hello!

I can’t send messages to my gmail account:

2013-12-31 19:39:55 1Vy4Gh-0006XN-Tj gmail-smtp-in.l.google.com [173.194.68.26] Connection timed out

I followed the tutorial and Exim instalation seems to be OK but Google’s network is not reachable. I prefer to suppose that the problem is with me and not on Google side. :-)

Any suggestions ?

Paulo Pimentel Droplet: propimentel

@KiwoT: Both should work fine. I think exim4 is more lightweight so if you are having problems with postfix’s memory usage you might want to consider replacing it with exim4.

How i Do create users?

Everything works just fine. Except if I send emails to the same domain the droplet is on.

I am using google apps mail and set up an alias sales@mydomain.com.au. the FQDN is mydomain.com.au

I can send to any other email from the server, except anyaddress@mydomain.com.au.

Any help witht his would be much appreciated.

Is there a way to install a web based front end to see the activity on this send only Exim4.

If possible please post a tutorial.

This comment has been deleted

I try to send but I get this message log

2015-03-15 15:37:11 1YXDKs-00059f-R9 aspmx.l.google.com [173.194.204.27] Connection timed out
2015-03-15 15:37:11 1YXDKs-00059f-R9 alt1.aspmx.l.google.com [2800:3f0:4003:c00::1b] Network is unreachable
2015-03-15 15:37:11 1YXDKs-00059f-R9 alt2.aspmx.l.google.com [2a00:1450:400b:c01::1a] Network is unreachable
2015-03-15 15:37:23 1YXDNc-0005Ec-K9 aspmx.l.google.com [64.233.171.27] Connection timed out
2015-03-15 15:37:23 1YXDNc-0005Ec-K9 alt2.aspmx.l.google.com [2a00:1450:400b:c01::1a] Network is unreachable
2015-03-15 15:37:23 1YXDNc-0005Ec-K9 alt1.aspmx.l.google.com [2800:3f0:4003:c00::1b] Network is unreachable
2015-03-15 15:38:33 1YXD7s-0004qK-IK alt1.aspmx.l.google.com [64.233.186.27] Connection timed out
2015-03-15 15:38:33 1YXD7s-0004qK-IK aspmx3.googlemail.com [2a00:1450:400b:c01::1b] Network is unreachable
2015-03-15 15:38:45 1YXD4O-0004ey-EN aspmx.l.google.com [173.194.204.27] Connection timed out
2015-03-15 15:38:45 1YXD4O-0004ey-EN alt2.aspmx.l.google.com [2a00:1450:400b:c01::1a] Network is unreachable
2015-03-15 15:38:56 1YXDP7-0005JM-Ke aspmx.l.google.com [64.233.171.27] Connection timed out
2015-03-15 15:38:56 1YXDP7-0005JM-Ke alt2.aspmx.l.google.com [2a00:1450:400b:c01::1a] Network is unreachable
2015-03-15 15:39:18 1YXDKs-00059f-R9 alt1.aspmx.l.google.com [64.233.186.27] Connection timed out
2015-03-15 15:39:31 1YXDNc-0005Ec-K9 aspmx3.googlemail.com [74.125.138.27] Connection timed out
2015-03-15 15:39:31 1YXDNc-0005Ec-K9 == eduardo@intrasis.com.br R=dnslookup T=remote_smtp defer (110): Connection timed out
2015-03-15 15:40:41 1YXD7s-0004qK-IK aspmx3.googlemail.com [74.125.138.27] Connection timed out
2015-03-15 15:40:41 1YXD7s-0004qK-IK == eduardo@intrasis.com.br R=dnslookup T=remote_smtp defer (110): Connection timed out