Easy 'mail by smarthost' SMTP server in Ubuntu 12.04 GNU/Linux

After being tasked with setting up some servers that need to use a local MTA (Mail Transfer Agent) (via SMTP) on our internal network, I found the setup for the Ubuntu 12.04 GNU/Linux exim4 MTA to be pleasingly simple. Easy Peasy, works for me!

Assuming you already have a main mail server in your organization that you can use as a "smarthost" relay, run through these simple steps and you will be up and running with a local SMTP server on your Ubuntu GNU/Linux box in no time.

1.) Install the MTA package on your Ubuntu 12.04 GNU/Linux box:

sudo apt-get install exim4-daemon-light

2.) Configure the MTA with this command and steps, replacing somedomain.com with your mail domain name:

sudo dpkg-reconfigure exim4-config

  • Set postmaster email: postmaster@somedomain.com
  • Select 'mail sent by smarthost; no local mail'
  • Set somedomain.com at the "System mail name" screen
  • Set defaults(hit enter) until you get to the step below
  • Enter mail.somedomain.com for the "IP address or host name of the outgoing smarthost:"
  • Set defaults all the way to the finish

That's it! exim4 should restart and you'll be ready to test. Now wasn't that easy?

Now check if the smtp server is listening on port 25 (smtp) with these terminal commands:

netstat -ano |grep :25

Should see something like:
tcp 0 0* LISTEN off (0.00/0/0)

Test the setup by sending an email to yourself from the Terminal:

echo "Yay - SMTP works" | mail -s "Test email" youremail@somedomain.com

That's it! Now you're free to go and get the beverage of your choice and drink to the awesomeness of the makers of FOSS/GNU/Linux/Ubuntu.


Shannon VanWagner

Popular posts from this blog

How To Connect Ubuntu Linux to Cisco VPN with openconnect (anyconnect-capable alternative)

(updated) How To: Ubuntu 16.04 GNU / Linux - Netgear Wireless AC Adapter AC600 ( AC6100 ) Dual Band

How To Set Default Grub / kernel / boot option on Ubuntu GNU/Linux 14.04