OK, so you want to use citadel, but installing and configuring postfix is a beast. An alternative, and frankly a much better solution is to use qpsmtpd. From the wiki:

The qpsmtpd daemon is written in pure Perl and can be customized easily. It consists of a core that implements a complete SMTP server, and a number of plug-ins that enhance the operations of the server. These plug-ins allow for the checking of recipients and senders, as well as virus scanning, spam checking, blocking lists (DNS and RHS), SMTP AUTH and TLS.

Is it ready for a production server?

Apache::Qpsmtpd embeds qpsmtpd in an Apache 2 server with mod_perl 2. This method is used by apache.org to handle over 2 million messages per day. Apache::Qpsmtp is currently included in the trunk. A setup exemple is available here.

The qpsmtpd daemon is easy to install and requires only a few simple pre-requisites. You need to install the following CPAN modules (use the cpan command to install these).

Net::DNS

MIME::Base64

Mail::Header

If you use a version of Perl older than 5.8.0, you will also need the following modules.

Data::Dumper

File::Temp

Time::HiRes

Moving on to the qpsmtpd installation, first, you need to download the qpsmtpd source code. I think using the source code gives a better picture of how qpsmtpd is put together but you can also install via RPM if you prefer. You can find instructions about how to install via RPM at the qpsmtpd Wiki.

The current release of qpsmtpd is version 0.32 and you can download it like so:

wget http://smtpd.develooper.com/files/qpsmtpd-0.32.tar.gz

(A slightly more recent version is available in the stable branch of the qpsmtpd subversion repository; it addresses some issues that have arisen since the last release. Download it via the svn tool.

svn co http://svn.perl.org/qpsmtpd/branches/0.3x qpsmtpd-0.3x)

Unpack the source code, change into the resulting directory, create the Makefile and make the package, like so:

Once the package is compiled, I strongly suggest you test it by doing:

# make test

My first time through, I didn't and missed some things during install.

Once the package is compiled, you can install it using the make install command.

# make install

This will install the Qpsmtpd.pm Perl module and its associated modules into the location of your Perl site files, for example, on a Linux-based host at /usr/lib/perl5/site_perl/5.8.8. The qpsmtpd and qpsmtpd-forkserver binaries will be installed into the /usr/bin directory.

Next, create a user to run qpsmtpd, I've chosen the user smtpd, like so:

# useradd smtpd -s /sbin/nologin

I have used the -s option to set the user's shell to /sbin/nologin, which prevents the smtpd user from logging in.

Now we want to create and configure some directories and basic configuration files. As a result of its heritage as a replacement for the qmail-smtpd daemon, the qpsmtpd daemon requires directories to be in a particular structure. The easiest way to implement this is to locate these directories off the home directory of the user qpsmtpd is running as. This allows qpsmtpd to find the required configuration files, logging directory and the plug-ins.

As a result of this non-FHS behavior, we're also going to create some symbolic links to make qpsmtpd look a bit more FHS compliant.

Create a configuration directory and populate it with the sample configuration files that are supplied with the qpsmtpd package.

Finally, we need to install the qpsmptd plug-ins by moving them out of the package directory. I usually choose to install the plug-ins into the /usr/share/qpsmtpd directory and link it back to the smtpd user's home directory.

Now you have installed qpsmtpd you can start it. The qpsmtpd daemon can be run in a number of different modes including tcpserver (using daemontools), a forkserver daemon (which forks for each new connection) and Apache::Qpsmtpd (where qpsmtpd is run via Apache 2 and mod_perl 2). There is also a pollserver daemon using Danga that is currently being developed and is not yet suitable for production use.

I'm going to examine running qpsmtpd via the forkserver daemon, which is considered the most popular mode and how perl.org and cpan.org both run their instances of qpsmtpd.

Earlier we installed the qpsmtpd-forkserver binary in the /usr/bin/ directory. Now we're going to symlink this binary into the ~smtpd directory to keep our configuration consistent.

# ln -s /usr/bin/qpsmtpd-forkserver ~smtpd

Once we've done this, we can start the qpsmtpd forkserver,

# ~smtpd/qpsmtpd-forkserver

This launches the forkserver in the foreground. Without any options the forkserver will bind to all available local IP addresses on port 2525 and wait to receive email. We can override these options on the command line like so,

The forkserver initiation on the previous line uses the –l option to specify the IP addresses to bind, here 127.0.0.1. The –p option specifies the port to bind to, in this case port 25. In the 0.32 release, you can only specify one IP address and port to bind to. In the 0.3x unstable release, you can specify the -l and -p options multiple times to bind to multiple IP addresses and ports.

The -u option indicates what user to run qpsmtpd as and the -d option tells the forkserver to detach and run as a daemon. If you omit the –d option, then qpsmtpd will run in the foreground. Lastly, the –pid-file option specifies the location of the daemon's PID file.