Setting Up a Mail Server

Last updated: March 9, 2001
Development stage: Beta

A mail server is a server that is running one or more of the following: an IMAP server, a POP3 server, a POP2 server, and an SMTP server. For now, I'm only going to cover installing IMAP4, POP3, and POP2, which all come in a single package. A few examples of SMTP servers are Sendmail (widely used) and QMail (more secure and configurable). Sendmail is installed on many Linux distributions by default so it might not be necessary at all to install it.

You may already have this installed on your system. As root, type which ipop3d and if it shows up, you don't need to read on unless you want to reinstall or perhaps to upgrade.

Download a file at ftp.cac.washington.edu called imap-4.1.BETA.tar.Z. It's about 1.3 megabytes in size, so if you want to back it up on a floppy disk later on, go ahead. Remember also, the version might change, so just look for a file in imap*.Z format. Also remember to set the transfer mode in FTP to binary so that you don't download the entire file as plain text. Do that by typing type binary or type image when you're logged into the FTP server. Also, downloading the file from your web browser will probably automatically transfer it in binary format.

Now, I'm assuming you've downloaded that archive already. If you haven't already, place it in /usr/local/src/ (or any directory you want, actually... but let me keep it simple) and extract it using tar -zxvf imap-4.1.BETA.tar.Z.

You should know by now that imap-4.1.BETA.tar.Z is only the name that I use as an example. There probably will be different and newer releases for that. Move into the directory it has extracted; in my case, that would be imap-4.1.BETA. Instead of just make from there on, you have to use make lnx to tell it how to set up the compiling and file formats. The "lnx" stands for Linux, and if you're using some other Unix implementation, read "Makefile" to find out which abbreviation you should use. If you're using shadow passwords on your server, you'll probably have to use make slx. Thanks to Charles Roth for figuring out and sharing this information.

Once you run make lnx from the imap-4.1.BETA directory (and yes, it will change from time to time), all the binaries should be compiled already and copied to /usr/sbin. The files it should have produced are imapd, ipop3d, and ipop2d. Those files should also be in the subdirectories, imapd and ipopd after imap-4.1.BETA. Do 'which imapd' and a 'which ipop3d' and see if they're in /usr/sbin/. Remember to do this as root if you plan to use the machine as a mail server. :)

This should already be present, but if it's not, put it in. Make sure that somewhere in /etc/inetd.conf, there are lines that read:

pop-2 	stream  tcp     nowait  root    /usr/sbin/tcpd  ipop2d
pop-3 	stream  tcp     nowait  root    /usr/sbin/tcpd  ipop3d
imap	stream 	tcp     nowait  root    /usr/sbin/tcpd	imapd

Common Problems

Here's a common error that people face: when someone sends a message to a user on your machine, the message is sent back to the sender and a copy of it is given to root also. This is what the error message looks like:

   ----- The following addresses had permanent fatal errors -----
<jgo@d67.local.net>

   ----- Transcript of session follows -----
553 d67.local.net. config error: mail loops back to me (MX problem?)
554 <jgo@d67.local.net>... Local configuration error

This was actually a sendmail configuration problem. I found out on IRC that I had to add a line to /etc/sendmail.cf in this format: Cw<host.name.net>. Even though I have a dynamic (constantly changing/randomly assigned) IP address, it works. I just entered the whole range of my possible IP addresses at the end of /etc/sendmail.cf (you can put this anywhere in sendmail.cf, but I just decided to put it at the end of the file because of this habit that I have...). This is what the end of my /etc/sendmail.cf file looks like:

Cwd50.local.net
Cwd51.local.net
Cwd52.local.net
Cwd53.local.net
Cwd54.local.net

... and so on. With those entries, I can accept incoming mail when I'm d50.local.net through d54.local.net. You can also just put in all your IP addresses and hostnames in /etc/sendmail.cw. I think that putting them in sendmail.cw in /etc/ is much easier, not to mention more convenient, than putting it in sendmail.cf, since sendmail.cf is the main sendmail configuration file, which should be kept free of clogging up.

More information on Sendmail can be accessed at http://www.sendmail.org. You can also order the book written on it, featured there on the Sendmail site.


Copyright © 1997-2001 Joshua Go (joshuago at users dot sourceforge dot net). All rights reserved. Permission to use, distribute, and copy this document is hereby granted. You may modify this document as long as credit to me is given.