Many Linux server applications need to send email. Cron jobs use mail services to deliver reports on jobs that have run, web applications require mail support for user registration functions, and other applications may need to send alerts via SMTP. This guide will help you install and configure the lightweight Exim MTA (Mail Transfer Agent) on your Ubuntu 12.04 LTS (Precise Pangolin) Linux VPS.
You'll gain the ability to send mail from localhost through either a traditional "sendmail" style interface, or via port 25 locally. As this guide is not intended to provide a full send/receive mail solution, please refer to our other email guides for ways to implement such configurations.
We assume that you've already followed the steps outlined in our getting started guide. If you're just getting acquainted with Linux systems, we also encourage you to review our using Linux guides. Make sure you're logged into your Linode as "root" via SSH before proceeding.
Before you begin installing and configuring the components described in this guide, please make sure you've followed our instructions for setting your hostname. Issue the following commands to make sure it is set properly:
hostname hostname -f
Make sure you have the "universe" repositories enabled. Your /etc/apt/sources.list file should resemble this:
## main & restricted repositories deb http://us.archive.ubuntu.com/ubuntu/ precise main restricted deb-src http://us.archive.ubuntu.com/ubuntu/ precise main restricted deb http://security.ubuntu.com/ubuntu precise-security main restricted deb-src http://security.ubuntu.com/ubuntu precise-security main restricted ## universe repositories deb http://us.archive.ubuntu.com/ubuntu/ precise universe deb-src http://us.archive.ubuntu.com/ubuntu/ precise universe deb http://us.archive.ubuntu.com/ubuntu/ precise-updates universe deb-src http://us.archive.ubuntu.com/ubuntu/ precise-updates universe deb http://security.ubuntu.com/ubuntu precise-security universe deb-src http://security.ubuntu.com/ubuntu precise-security universe
Issue the following commands to update your package repositories, upgrade your system, and install Exim:
apt-get update apt-get upgrade apt-get install exim4-daemon-light mailutils
Now you're ready to configure Exim for local mail service. Here's how:
Enter the following command to start Exim configuration:
You'll be presented with a welcome screen, followed by a screen asking what type mail delivery you'd like to support. Select the option for internet site, and then select Ok to continue.
9. Accept the default non-split option for your mail configuration file. Enter at least one external email address (choose one that you check frequently) in addition to root when asked to specify postmaster mail recipients.
Issue the following command to send a test email, substituting an external email address for email@example.com.
echo "This is a test." | mail -s Testing firstname.lastname@example.org
Congratulations! You've configured Exim to send email from your Linux VPS.
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This guide is licensed under a Creative Commons Attribution-NoDerivs 3.0 United States License.
Last edited by Alex Fornuto on Tuesday, January 21st, 2014 (r4127).