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 127.0.0.1:25 0.0.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.

Cheers!

Shannon VanWagner
04-30-2012



Comments

  1. Great post, but how do i create new user acounts so they can use the mail server?

    ReplyDelete
  2. great post, but how can i create new email accounts ???

    ReplyDelete
  3. Very helpful - Thanks Shannon!

    ReplyDelete
  4. It sometimes works better to actually relay everything to a smarthost, like smtp.gmail.com.

    I made a script for automatic installation and configuration of postfix, to act as a relay for gmail smarthost.

    Feel free to check out https://gist.github.com/3952294

    ReplyDelete

Post a Comment

Thanks for commenting. Comments are moderated by the blog owner and will appear once approved. Need to email me directly? Go to http://shannonvanwagner.com/email-me.php

Popular posts from this blog

On Helping Others Get their GNU/Linux & Consider Doing So

How To: Install Wordpress on Manjaro Linux Pahvo 21.1.0

How to Disable Middle Mouse Button in Ubuntu / Debian Linux