A Site by Jaysam Thanki, Web Architect

TNMailServer

How to read this document

Quiet Simple. Text in this current font is informative text. Text that is highlighted, will follow an optional scheme that will flow through out the document as stated. Stuff in Courier, bounded in a box is stuff you type into a terminal window. There will be embedded bounded boxes, which represent the contents of a new file altogether, or as stated. Stuff that is bounded in a box, that is bold, represents statements that should be executed as root. For the most part, everything in the bounded boxes can be cut n pasted right into a putty window, i've put things in red/white text to designate you may need to wait or have a prompt.

Components

This is an opensource project, so thus we need an open source operating sstem to put this all on. This document is currently made for Slackware. As of writing, the latest version of Slackware is 12.0. This document assumes that you hvae a plain vanilla install of Slackware. If you do a complete install with the basic packages (Base, Development, Networking), you should be in good shape. Simply run pkgtool and remove apache, php, mysql, sendmail, imap and pop3. I'm also simultaneously making this server in Redhat Fedora, so i'll point out any changes for redhat.

Here is the list of components we'll need, download them now.

#as root.. lets create a user for us to work with
useradd -s /bin/bash -c 'Build User' user
mkdir /home/user
chown user.users /home/user
#if you want to ever login as this user, please rememeber to set a password on this account.

#switch to the user
su user

#as regular user
cd
mkdir build
mkdir src
cd src

#TNMailServer Scripts
wget http://techie.org/downloads/tnmailserverscripts-1.4.1.tgz

#MySQL 5.0
#Unfortunately, since their are so many versions now, grab the version you require for your machine
#http://dev.mysql.com/downloads/mysql/5.0.html

#Cyrus-SASL 2.1.21
wget ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.22.tar.gz

#Postfix 2.4.3
wget http://www.tigertech.net/mirrors/postfix-release/official/postfix-2.4.3.tar.gz
wget http://vda.sourceforge.net/VDA/postfix-2.4.3-vda-ng.patch.gz

#Courier Imap 4.1.3
wget http://superb-east.dl.sourceforge.net/sourceforge/courier/courier-imap-4.1.3.tar.bz2
wget http://home.raxnet.net/downloads/courier-imap/courier-imap-sql-updates.patch
wget http://umn.dl.sourceforge.net/sourceforge/courier/courier-authlib-0.59.3.tar.bz2

#Apache 2.2.4
wget http://www.signal42.com/mirrors/apache/httpd/httpd-2.2.4.tar.bz2

#PHP 5.2.3
wget http://us.php.net/get/php-5.2.3.tar.bz2/from/www.php.net/mirror

#SquirrelMail 1.4.10a
wget http://superb-east.dl.sourceforge.net/sourceforge/squirrelmail/squirrelmail-1.4.10a.tar.bz2
wget http://www.squirrelmail.org/plugins/change_sqlpass-3.3-1.2.tar.gz
wget http://www.squirrelmail.org/plugins/compatibility-2.0.8-1.0.tar.gz
wget http://www.squirrelmail.org/plugins/check_quota-1.4-1.2.7.tar.gz

#Clam AntiVirus 0.91.1
wget http://umn.dl.sourceforge.net/sourceforge/clamav/clamav-0.91.1.tar.gz

#Amavisd-new 2.5.2
wget http://www.ijs.si/software/amavisd/amavisd-new-2.5.2.tar.gz

#TNMailServer Administration tool 2.0
wget http://www.techie.org/downloads/tnmailserveradmin-2.0.0.zip

#TNMailServer AutoResponder tool 1.2.0
wget http://www.techie.org/downloads/tnmailserverautoresponder-1.2.0.tgz

#TNMailServer Notify tool 1.0.0
wget http://www.techie.org/downloads/tnmailservernotify-1.0.0.tgz

#RRDTool 1.2.10
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.23.tar.gz
wget http://www.infodrom.org/projects/cgilib/download/cgilib-0.5.tar.gz

#MailGraph 1.11
wget http://mailgraph.schweikert.ch/pub/mailgraph-1.13.tar.gz
							
As you can see, I put all of the above into a "src" directory, in a normal users account. I don't like building things as root, so everything (unless stated otherwise) should be built as non root. Certain packages will not compile as root. Anything you see in this document that is bold means it has to be done as root. All stuff in italics means you can change it to your desired value.
I am also keeping an archive of all the files used. If you cannot find a particular package, please email me using my contact form.

Installation

MySQL

MySQL is a fabulous community database server, which is what i have chosen to use to store all account information. However, MySQL has evolved a lot now and is avaialble in so many different flavours, i cannot explain how to install it on your distribution. If you have MySQL already installed on your system, that should be fine to use. Otherwise, you will need to do something like this to install it.
#as regular user
cd
cd build
tar -xzf ../src/mysql*

su
mv mysql* /usr/local/mysql
cd /usr/local

#User/Group may exist, but its ok to issue these commands and ignore errors.
groupadd mysql
useradd -s /bin/false -c "MySQL" -g mysql mysql

cd mysql
scripts/mysql_install_db

chown -R root .
chown -R mysql data
chgrp -R mysql .

#if using slackware, use this to put it in the rc.d
#cp support-files/mysql.server /etc/rc.d/rc.mysql
#if using redhat, or something else, use this to put it into init.d
#cp support-files/mysql.server /etc/init.d/mysql

#you can copy a different file, or edit if you want
cp support-files/my-medium.cnf data/my.cnf

support-files/mysql.server start

#wait for mysql to start before pasting in the below text

#set net password on the sql server
./bin/mysqladmin -u root password 'new-password'

#Make a sym link to easily access mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysql_config /usr/bin/mysql_config
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
ln -s /usr/local/mysql/bin/replace /usr/bin/replace
							
Ok.. MySQL installed and running.. Drop back to the regular build user, and run the tnmailserver.sql scripts.
#(as regular user)
cd
mysql -u root -p < build/tnmailserver-1.4.1/tnmailserver.sql
							
Ok great, we have MySQL running with my database installed!

Cyrus SASL

Cyrus will provide your system a Secure Authentication System Library (SASL). Postfix use the system's SASL lib's to provide ESMTP/SMTP-AUTH Capability. Your system may or may not come with SASL2. This will install sasl2 for you with MySQL support.
cd
cd build
tar -xzf ../src/cyrus-sasl-*
cd cyrus-sasl-*
env CPPFLAGS="-I/usr/local/mysql/include" \
    LDFLAGS="-L/usr/local/mysql/lib -lmysqlclient -lz" \
    ./configure --with-mysql --enable-login --enable-sql --disable-otp

make
su

make install
#Sym link to /usr/lib for compatibility...
ln -s /usr/local/lib/sasl2/ /usr/lib/sasl2
ln -s /usr/local/lib/libsasl2.so /usr/lib/libsasl2.so
ln -s /usr/local/lib/libsasl2.so.2 /usr/lib/libsasl2.so.2

#copy pre-configured file
cp ../tnmailserver-1.4.1/smtpd.conf /usr/lib/sasl2/smtpd.conf

							
Great, its installed. That's it. We will secure this file later since it does contain sensitive information.

Postfix

Postfix is the heart of this mailserver. Wietse also keeps it up to date with all the leet hackers out there trying to hack away and send spam. We configure it with support for MySQL and SASL (provided by Cyrus).
#as regular user
cd
cd build
tar -xzf ../src/postfix-2.4.3.tar.gz
cd postfix-2.4.3

#apply this wonderful VDA patch by http://vda.sourceforge.net/
gunzip ../../src/postfix-2.4.3-vda-ng.patch.gz
patch -p1 < ../../src/postfix-2.4.3-vda-ng.patch

#Add support for mysql and SASL
make -f Makefile.init makefiles \
'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include -DUSE_SASL_AUTH -I/usr/local/include/sasl' \
'AUXLIBS=-L/usr/local/mysql/lib -lmysqlclient -lz -lm -L/usr/local/lib -lsasl2'

make

su

#kill old sendmail completetly (safe to ignore any errors)
mv /usr/sbin/sendmail /usr/sbin/sendmail.OFF
mv /usr/bin/newaliases /usr/bin/newaliases.OFF
mv /usr/bin/mailq /usr/bin/mailq.OFF
chmod 755 /usr/sbin/sendmail.OFF /usr/bin/newaliases.OFF /usr/bin/mailq.OFF

#create accounts
#note these accounts get assigned a id by the system. Please make sure
#that postfix and postdrop do NOT have the same uid and gid
#(not 100 and 100, but 101 and 102 is fine)
groupadd -g 12345 postfix
useradd -u 12345 -g 12345 postfix -d /dev/null -s /bin/false
groupadd -g 54321 postdrop

#Install!
make install

#While running make install, accept all the defaults. My install depends on them. Ignore warnings

echo 'postmaster: root' >> /etc/aliases
echo 'postfix: root' >> /etc/aliases

#install our custom config (not really custom)
rm /etc/postfix/main.cf
cp ../tnmailserver-1.4.1/main.cf /etc/postfix/main.cf
cp ../tnmailserver-1.4.1/TNMailServer* /etc/postfix/

							
Let me explain what i did with my tables and such. You may have noticed that ForwardAddress and EmailAddress are mostly the same data. Why oh why, do you ask. Answer is, I think I've found a bug in postfix that threw me off (and a lot of other people I see). Basically, postfix checks the alias table first for the email address receiving mail. If it finds it, it stops there and forwards. If it doesn't, then it looks for @domain.tld as a catch all. If it finds, it forwards there. That's where my dilemma came in, and the only solution I've come across thus far, is to keep email address and forward address identical. Any other solution with just two tables will always yield in a catch situation for all emails. I'll keep thinking and if I find a solution, I'll post here. Also, @domain.tld in the Emailaddress is catchall. If the forwardaddress is null, then no catchall is done. Ok to finish off...
#create our mail repository
mkdir /var/spool/postfix/virtual
chown postfix.postdrop -R /var/spool/postfix/virtual
chmod a-rwx -R /var/spool/postfix/virtual
chmod ug+rwx -R /var/spool/postfix/virtual

#secure the smtpd.conf file in sasl2
chmod a-rwx /usr/lib/sasl2/smtpd.conf
chown root.postdrop /usr/lib/sasl2/smtpd.conf
chmod ug+rw /usr/lib/sasl2/smtpd.conf

#create the alieses.db
newaliases

postfix start
							
Postfix should now be running.

Courier IMAP

Courier IMAP is a imap/pop/ssl demon that works great with MailDir's. Since version 4.0, courier has split up the imap server from the actual server with the authentication, to the server without the authentication. So we require an AuthLib setup first. This handles all of our sql authentication for accounts. On with courier setup..
#as regular user
cd
cd build
tar -xjf ../src/courier-authlib-*
cd courier-authlib-*
env CPPFLAGS="-I/usr/local/mysql/include" \
LDFLAGS="-L/usr/local/mysql/lib -lmysqlclient -lz" \
./configure --without-authvchkpw --without-authdeamon \
--without-authuserdb --without-authpam --without-authldap \
--without-authpwd --without-authshadow --without-authpgsql \
--without-authcustom --without-authpipe --with-authmysql \
--with-authmysql-libs=/usr/local/mysql/lib \
--with-authmysql-includes=/usr/local/mysql/include
make
make check
su


make install-strip
make install-configure
cp courier-authlib.sysvinit /etc/rc.d/rc.courierauthlib
chmod 755 /etc/rc.d/rc.courierauthlib

#copy preconfigured file...
cp ../tnmailserver-1.4.1/authmysqlrc /usr/local/etc/authlib/authmysqlrc


#back to regular user
cd
cd build
tar -xjf ../src/courier-imap-4.0.3.tar.bz2
cd courier-imap-4.0.3
./configure --prefix=/usr/local
make
make check
su

make install-strip
make install-configure
cp courier-imap.sysvinit /etc/rc.d/rc.imapd
chmod 755 /etc/rc.d/rc.imapd

#copy preconfigured files
cp ../tnmailserver-1.4.1/imapd /usr/local/etc/
cp ../tnmailserver-1.4.1/pop3d /usr/local/etc/
#if you want ssl, copy these as well.
cp ../tnmailserver-1.4.1/imapd-ssl /usr/local/etc/
cp ../tnmailserver-1.4.1/pop3d-ssl /usr/local/etc/

#create initial folders
mkdir /var/spool/postfix/virtual/domain.tld
/usr/local/bin/maildirmake /var/spool/postfix/virtual/domain.tld/abuse/
/usr/local/bin/maildirmake /var/spool/postfix/virtual/domain.tld/root/
/usr/local/bin/maildirmake /var/spool/postfix/virtual/domain.tld/spam/
/usr/local/bin/maildirmake /var/spool/postfix/virtual/domain.tld/postmaster/
/usr/local/bin/maildirmake /var/spool/postfix/virtual/domain.tld/user/
chown postfix.postdrop /var/spool/postfix/virtual/domain.tld -R
chmod 700 /var/spool/postfix/virtual/domain.tld -R

#start authentication deamon
/etc/rc.d/rc.courierauthlib start
#start courier imap
/etc/rc.d/rc.imapd start

							
If everything installed, then you now techinincally have a full mailserver ready to go. Test it out using Outlook Express. Use user@domain.tld as the login, and pass as the password.

Apache

Apache is a great web server for simple appliances. I'm using version 2 of this web server which is now deemed to be safe and stable.
#as regular user
cd
cd build
tar -xzf ../src/httpd-2.0.54.tar.gz
cd httpd-2.0.54
./configure --enable-so --enable-suexec --with-suexec-caller=nobody --enable-ssl
make
su

make install
rm /etc/rc.d/rc.httpd
cp /usr/local/apache2/bin/apachectl /etc/rc.d/rc.httpd
#make the postfix/tnmailserveradmin connector dir
mkdir /usr/local/apache2/htdocs/postfix-cgi-bin
chown postfix.postdrop /usr/local/apache2/htdocs/postfix-cgi-bin
chmod 755 /usr/local/apache2/htdocs/postfix-cgi-bin

							
Apache installed!

PHP

PHP is a superb Scripting language, which has flaws. But hey, it works, its free, its fast. It's also a cinch to install with apache. We will be installing the module, cli and cgi versions of php.
#as regular user
cd
cd build
tar -xjf ../src/php-*
cd php-*
./configure --with-mysql --with-apxs2=/usr/local/apache2/bin/apxs
make
su

make install
cp php.ini-recommended /usr/local/lib/php.ini

							
PHP is now installed. We need to make some changes to apache... Edit /usr/local/apache2/conf/httpd.conf and check the following
nano /usr/local/apache2/conf/httpd.conf

#Look for php5 in the file, and verify that the line

LoadModule php5_module modules/libphp5.so

#is present
#and then look for addtype block and verify that

AddType application/x-httpd-php .php .phtml

#is there, if not add it. Also add index.php and default.php to the line 

DirectoryIndex index.html index.html.var index.php default.php

#Save and..
#start apache
/etc/rc.d/rc.httpd start
							
You should now have a web server running, check by browsing to http://your.domain.tld

Squirrel Mail

cd
cd build
tar -xzf ../src/squirrelmail-1.4.5.tar.gz
tar -xzf ../src/change_mysqlpass-3.2-1.2.8.tar.gz
tar -xzf ../src/compatibility-2.0.tar.gz
tar -xzf ../src/check_quota-1.4-1.2.7.tar.gz

#create webmail user account
mkdir /usr/local/apache2/Sites

mv squirrelmail-1.4.5 /usr/local/apache2/Sites/webmail
mv change_mysqlpass /usr/local/apache2/Sites/webmail/plugins
mv compatibility /usr/local/apache2/Sites/webmail/plugins
mv check_quota /usr/local/apache2/Sites/webmail/plugins
cp /usr/local/apache2/Sites/webmail/plugins/check_quota/config.php.sample /usr/local/apache2/Sites/webmail/plugins/check_quota/config.php

mkdir /usr/local/apache2/Sites/data
mkdir /usr/local/apache2/Sites/attach

cp /usr/local/apache2/Sites/webmail/data/default_pref /usr/local/apache2/Sites/data
chmod -R 770 /usr/local/apache2/Sites/data
chmod -R 770 /usr/local/apache2/Sites/attach
chmod -R 755 /usr/local/apache2/Sites/webmail
chown root.nobody -R /usr/local/apache2/Sites/

#We need Pear::DB package for squirrel.. install it
pear install DB

#restart apache
/etc/rc.d/rc.httpd graceful
							
That's it! Check it by browsing to your machine http://webmail.domain.tld and you should get squirrel responding!

Clam Antivirus

ClamAV is a open source virus checker, that works, and well.. is free! so here goes..
#as regular user
cd
cd build
tar -xzf ../src/clamav-*
cd clamav-*
./configure --disable-clamav
make

su
groupadd clamav
useradd -s /bin/false -c "ClamAV" clamav -g clamav
make install
#test it..
clamscan test


touch /var/log/freshclam.log
chown clamav.clamav /var/log/freshclam.log
mkdir /var/lib/clamav
chown clamav.clamav /var/lib/clamav

freshclam

#after its done, cron a daily job to keep doing it..
cp ../tnmailserver-1.4.1/virusdefupdate /etc/cron.daily
chmod 700 /etc/cron.daily/virusdefupdate

#copy premade configuration file
cp ../tnmailserver-1.4.1/clamav.conf /usr/local/etc/clamd.conf

mkdir /tmp/clamav
chown clamav.clamav /tmp/clamav

							
Antivirus, installed.

Spam Assassin

Spam Assassin is pretty much one of the most standard antivirus engines around, used in tonnes of things. We'll install it via CPAN cos its easier.

#enter cpan
perl -MCPAN -e shell

#once loaded, you may need to set it up ifyou never used it, so do that.
install Mail::SpamAssassin

#watch for prompts

							
Ok, installed.

Amavis

Amavis is a program that links the entire filteration process. The flow is simple. Mail comes into postfix, gets filtered for relays and valid email addresses, it then sends the mail to amavis which runs a spamassassin on it, and clamav scan on the email, before finally returning it to postfix for final delivery (either to a forwarded account or a mailstore)
#as regular user
cd
cd build
tar -xzf ../src/amavisd-new-*
cd amavisd*

#invoke cpan to intall stuff
perl -MCPAN -e shell
install Archive::Tar Archive::Zip Convert::TNEF Convert::UUlib MIME::Base64 Mail::Internet #Net::Server Net::SMTP Time::HiRes Unix::Syslog BerkeleyDB
exit

chown root.root amavisd
chown root.root amavisd.conf
chown root.root amavisd_init.sh

cp amavisd /usr/sbin
#copy basic configuration, please edit this file for your needs
cp ../tnmailserver-1.4.1/amavisd.conf /etc
chown root.root /etc/amavisd.conf

groupadd amavis
useradd -s /bin/false amavis -g amavis
mkdir /var/amavis
mkdir /var/amavis/tmp /var/amavis/var /var/amavis/db
chmod 750 /var/amavis -R
chown amavis.amavis /var/amavis -R

mkdir /var/virusmails
chmod 750 /var/virusmails
chown amavis.amavis /var/virusmails
chown amavis /tmp/clamav

#still as root
#Start Clamd
clamd
#Start amavis
amavisd start


#uncomment the content-filter line in /etc/postfix/main.cf
postfix reload

							
Mailserver with filtering. DONE

TNMailServer Administration

The folks here at Techie Networks wrote this simple php management script, for domains. Basically, any account with the SQL flag for IsAdmin set to 1 or 2, can login using their email address and manage the accounts in their domain. Users with IsAdmin set to 0 will only be able to modify their own settings (name and password and autorespond). With IsAdmin set to 2, the user will becomg a global admin and can create domains.
#as webmail user
#setup the PEAR modules we need for webservices.
cd /home/webmail/homepage
mkdir admin
cd admin
unzip ../../tnmailserveradmin-2.0.0.zip

#now edit the security.php file, and update database settings (use iusr_mailadmin for db user)
#pico include/security.php

cp cgi-bin/* /usr/local/apache2/htdocs/postfix-cgi-bin
chown postfix.postdrop -R /usr/local/apache2/htdocs/postfix-cgi-bin
chmod 755 /usr/local/apache2/htdocs/postfix-cgi-bin/*

#fix windows linefeed problems
#just put a space and remove it,then save.
pico /usr/local/apache2/htdocs/postfix-cgi-bin/postfixhelper.php

							
With the above done, you should now have a working admin page. try http://webmail.domain.tld/admin and login with a "root" account that's specified in the example. Note, the cgi interface that creates the maildir's and domain directorys runs as postfix.postdrop user from the htdocs folder within apache.

TNMailserver AutoResponder

After countless hours spent looking for a decent forwarding and auto responding mechanism, i came to this script by www.high5.net called vacation. Although its not designed to work with TNMailserver, i hacked it to do so, and also renamed it from vacation, to "AutoResponder" which is what it really is. It is basically the same code as vacation though, only with a different sql query for the look ups.

The basic principle behind this autoresponder is simple. Anyone who needs automatic responses, forwards their mail to a known SYSTEM account, in my examples, this is autoresponder@hostname.domain.tld. This *must* be a real system Unix account, that has abilities to run procmail. Procmail comes standard with slackware. After a mail is forwarded to this account, a .forward file is executed, which activates a perl script. This perl script looks in the mysql database for the text to respond back with, and sends it. Simple as that.

To install:
cd
cd build
tar -xzf ../src/DB_File-1.811.tar.gz
tar -xzf ../src/DBI-1.48.tar.gz
tar -xzf ../src/DBD-mysql-3.0001.tar.gz

cd DB_File-1.811
perl Makefile.PL
make
cd ../DBI-1.48
perl Makefile.PL
make
make test
su

make install
cd ../DB_File-1.811
make install

#back to regular user
cd ../DBD-mysql-3.0001
perl Makefile.PL --testuser=iusr_mailadmin --testpassword=password \
--cflags="-I/usr/local/mysql/include" \
--libs="-L/usr/local/mysql/lib -lmysqlclient -lz"
make

su
make install

useradd -s /bin/bash -d /home/autoresponder -c "Autoresponder account" autoresponder
mkdir /home/autoresponder
cp ../../src/tnmailserverautoresponder-1.2.0.tgz /home/autoresponder
cd /home/autoresponder
tar -xzf tnmailserverautoresponder-1.2.0.tgz
rm tnmailserverautoresponder-1.2.0.tgz
chown autoresponder.users -R ../autoresponder/

							
Thats it!

TNMailServer Notify

After a user request for this feature, it made sense so I'm adding it in. It's based upon the autoresponder above, so the code is very similar. This code basically notifies a user that they have email waiting for them, which is set through the administration tool.

To install:
							
useradd -s /bin/bash -d /home/notify -c "Notify account" notify
mkdir /home/notify
cp src/tnmailservernotify-1.0.0.tgz /home/notify
cd /home/notify
tar -xzf tnmailservernotify-1.0.0.tgz
rm tnmailservernotify-1.0.0.tgz 
chown notify.users -R ../notify

							
Done!

RRDTool

RRDTool is required to get mailgraph to run. Pretty straight forward install. So here goes
#as regular user
cd
cd build
tar -xzf ../src/cgilib-0.5.tar.gz
tar -xzf ../src/rrdtool-1.2.10.tar.gz
cd cgilib-0.5
make CC=gcc CFLAGS="-O3 -fPIC -I."
mkdir -p ../rrdtool-1.2.10/lb/include
cp *.h ../rrdtool-1.2.10/lb/include
mkdir -p ../rrdtool-1.2.10/lb/lib
cp *.o ../rrdtool-1.2.10/lb/lib
cp libcgi* ../rrdtool-1.2.10/lb/lib
cd ..
tar -xjf ../src/freetype-2.1.10.tar.bz2
cd freetype-2.1.10/
./configure
make

su
make install


#as regular user
cd
cd build
cd rrdtool-1.2.10
env CPPFLAGS="-I/usr/local/include/freetype2 -I`pwd`/lb/include" \
LDFLAGS="-L`pwd`/lb/lib" \
./configure --enable-perl-site-install
make

su
make install
make site-perl-install
ln -s /usr/local/rrdtool-1.2.10/bin/rrdtool /usr/bin/rrdtool
ln -s /usr/local/rrdtool-1.2.10/bin/rrdupdate /usr/bin/rrdupdate

							
That should be it for rrdtool... onto mailgraph...

Mailgraph

Mailgraph is a simple tool that sits, tail's the maillog file and generates graphs upon request. It runs as a cgi module. To install
#as regular user
cd
cd build
tar -xzf ../src/File-Tail-0.99.1.tar.gz
tar -xzf ../src/mailgraph-1.11.tar.gz
cd File-Tail-0.99.1/
perl Makefile.PL
make

su
make install
mkdir /usr/local/mailgraph
chown postfix.postdrop /usr/local/mailgraph
cd ../mailgraph-1.11
cp mailgraph.cgi /usr/local/apache2/htdocs/postfix-cgi-bin/
cp mailgraph.pl /usr/local/mailgraph
chown postfix.postdrop /usr/local/apache2/htdocs/postfix-cgi-bin/mailgraph.cgi
chmod 755 /usr/local/apache2/htdocs/postfix-cgi-bin/mailgraph.cgi 

cp mailgraph-init /etc/rc.d/rc.mailgraph
chmod 755 /etc/rc.d/rc.mailgraph

pico -w /etc/rc.d/rc.mailgraph
#Edit the vars to match the following
MAILGRAPH_PL=/usr/local/mailgraph/mailgraph.pl
MAIL_LOG=/var/log/maillog
PID_FILE=/var/run/mailgraph.pid
RRD_DIR=/usr/local/mailgraph
pico -w /usr/local/apache2/htdocs/postfix-cgi-bin/mailgraph.cgi 
#Edit all the settings for the cgi file to find the location of the rrd files
my $rrd = '/usr/local/mailgraph/mailgraph.rrd'; # path to where the RRD database is
my $rrd_virus = '/usr/local/mailgraph/mailgraph_virus.rrd'; # path to where the Virus RRD database is

#To Start MailGraph (remember to put the following line in your rc.X
/etc/rc.d/rc.mailgraph start

							
Once this is set, you can check at http://hostname.domain.tld/cgi-bin/mailgraph.cgi

Post Install Recommendations

After installing and everything tests great with the domain.tld test, i recommend the following
  • Edit Postfix main.cf (/etc/postfix/main.cf) and removed domain.tld, and hostname.domain.tld and replace with a real domain, preferably ther real fqdn of the machine
  • Delete all the rows from all the tables in mysql by issuing "DELETE FROM TNSession; DELETE FROM TNAccount; DELETE FROM TNDomain;" then insert real records for the correct hostname, and make a "Super Admin" root account. Scripts for this will follow shortly. Set the IsAdmin flag to 2 for this super admin.
  • Delete the virtual domain.tld folder from /var/spool/postfix/virtual
  • Edit apache and make a real webmail.domain.tld website
  • Change the passwords on the sql server for all of the accounts created. The accounts are postfix,sasl,courier,autoresponder,iusr_mail,iusr_mailadmin.
  • Edit the files related to the changed passwords. /usr/local/lib/sasl2/smtpd.conf, /usr/local/etc/authlib/authmysqlrc, /etc/postfix/TNMailServer*.cf and if you installed the tnmailserveradmintoold, /home/webmail/homepage/admin/include/config.php