Software

DIY IT: Email server on a shoestring budget

Jack Wallen shows how to install and set up a Postfix mail server on a server on which you installed eGroupware.

Recently I did a blog on the installation of eGroupware to be used as an Exchange replacement (See my blog DIY IT: Groupware on a shoestring budget.) The suite is very powerful and makes an outstanding substitute for Exchange. But during that article I mentioned the necessity of having a previously installed and configured mail server. Without that mail server, the groupware server is fairly pointless (unless you just need a calendar server.)

So, what about the email server? What can you do? The answer to that is not only simple, it's also cheap. You can install and set up a Postfix mail server on that same server you install eGroupware. The combination of Postfix and eGroupware is quite a solid one, so let's not waste any time and get that Postfix server up and running.

This mail server will be install on the same machine as our eGroupware machine. For this example I will use a Ubuntu 10.10 installation. You will want to already have your domain purchased and your IP addressed routed. With all of that out of the way, you are ready to begin.

Installation

The installation of the mail server itself is very easy. All that is needed is a terminal window and sudo access. Here are the steps for the installation.

  1. Open up a terminal window. If the machine is a GUI-less server, just log in.
  2. Issue the command sudo apt-get install postfix.
  3. Type your sudo password and hit Enter.
  4. Allow any dependencies to be installed.
  5. Let the installation finish.

When the installation is finished, the Postfix daemon should be running. Test the connection from the command line by issuing the command:

telnet localhost 25

The above command will attempt to make a connection to the machine on port 25, which is the listing port for the mail server. If it connects, Postfix is up and running and should report back something like:

Trying 127.0.0.1...

Connected to localhost.

Escape character is '^]'.

220 localhost.localdomain ESMTP Postfix (Ubuntu)

If the above text is presented, Postfix is ready to be configured. If a connection can not be made, the firewall rules might have to be checked, or the Postfix daemon may need to be restarted. To restart the daemon, enter the command:

sudo /etc/init.d/postfix start

After the daemon has started, attempt to connect again.

Configuration

The configuration of Postfix will make up the bulk of the work here, but it's still a fairly simple process. In fact, Postfix might well be the email server with the simplest configuration. Here's how it works.

Postfix only has one main configuration file: /etc/postfix/main.cf. Open up that file in a text editor and look for the following options:

myhostname =

mydestination =

mynetworks =

Configure these options according to the following guidelines:

  • myhostname: This is the hostname of your mail server. Make sure to not place the FQKN here. For example, if the domain is my.domain.com, only enter domain for the myhostname option.
  • mydestination: This declares where the mail server will be delivering to locally. The default is: mydestination = $myhostname localhost.$mydomain localhost. Most likely the default will work just fine.
  • mynetworks: Here is where valid networks are defined. For example, an entry here if 127.0.0.1/8 would only deliver to the local machines. Generally speaking, that will not work. An entry similar to mynetworks = 127.0.0.1/8 192.168.100.1/24 will deliver  to both local machines and within a LAN based on the 192.168.100.1 address scheme. For an email server to deliver internally and externally, configure this option like so: mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128

If your mail server needs to deliver mail to an entire domain, add another entry to the section above like:

mydomain=mydomain.com

where mydomain.com is the actual domain.

Save that configuration file and restart the postfix daemon with the command:

sudo /etc/init.d/postfix reload

The mail server is now up and running!

Users

Remember, this is a Linux email server, so in order for a user to have an email account, they must have an account on the server. This is simple. Back to the terminal window issue the command:

sudo useradd -m USERNAME

Where USERNAME is the actual name of the user to be added. This command will be followed by a request to enter a password for the new user. Once that is complete, the user should now be able to use their account on the mail server.

Final thoughts

At this point, the groupware suite can be installed on top of the email server. Once that is complete, the users should be able to log onto the groupware tool and take advantage of web-based email. Of course this article only touches the surface of getting the email server up and running. There are always security concerns for any type of mail server, but that is another conversation for another day. But this does show how easy it is to get an email server up and running on the cheap!

About

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.

3 comments
greavette
greavette

I agree...Citadel is extremely easy to setup...We use Citadel in our office (with Thunderbird through IMAP). We also have egroupware installed and use it as a common addressbook for our Thunderbird clients. I would prefer to use Citadel through egroupware but could never get it connected. I'd be interested to hear how to setup Citadel with egroupware too.

Alpha_Dog
Alpha_Dog

...though it may be easier to just install citadel or zential.

pgit
pgit

I agree if you just want an email system, citadel is as easy as it gets. I think Jack was interested in the whole egroupware suite with this. I'm not sure but it would seem parts of the citadel web interface might conflict with egroupware. How about it, Jack? Could a citadel mail server work as the back end to egroupware?

Editor's Picks