Configuring a fully featured Exim mail server on Centos 4.x
Exim + VExim + ClamAV + Spamassassin + Courier-IMAP + Squirrelmail + Mailman
Index
Software installation
Install the RPMForge Repository
Install the required packages
yum install exim clamd squirrelmail httpd mod_ssl mailman spamassassin mysql mysql-server php-mysql
Remove sendmail/postfix
yum remove sendmail postfix
Configure the services to start on boot
for daemon in spamassassin clamd httpd mysqld do chkconfig $daemon on service $daemon start done
ClamAV + SpamAssassin
Exim
Rebuild Exim for Mysql support
wget http://mirror.centos.org/centos-4/4.3/os/SRPMS/exim-4.43-1.RHEL4.5.src.rpm rpm -ivh exim-4.43-1.RHEL4.5.src.rpm cd rpm/SOURCES/
Edited exim-4.43-config.patch for mysql support
$ diff exim-4.43-config.patch exim-4.43-config.patch.mysql 61c61 < @@ -253,16 +253,18 @@ --- > @@ -253,16 +253,19 @@ 75,76c75,78 < +LOOKUP_LIBS=-lldap -llber < # LOOKUP_MYSQL=yes --- > +LOOKUP_LIBS=-lldap -llber -L/usr/lib64/mysql -lmysqlclient > +LOOKUP_INCLUDE=-I/usr/include/mysql > -# LOOKUP_MYSQL=yes > +LOOKUP_MYSQL=yes
VExim
Set the mysql root password
mysqladmin -u root password 'new-password'
Create the VExim database
mysqladmin -u root -p create vexim
Create the VExim user and mail repository
useradd vexim -u 90 -d /home/vexim -s /sbin/nologin -m
cd /usr/src wget http://silverwraith.com/vexim/vexim2.2RC1.tar.gz tar xvzf /usr/src/vexim2.2RC1.tar.gz
SITEADMINPASS=<password> VEXIMPASS=<randompass> sed -i -e "s#uid smallint(5) unsigned NOT NULL default 'CHANGE',#uid smallint(5) unsigned NOT NULL default '90',#" vexim2/setup/mysql.sql sed -i -e "s#gid smallint(5) unsigned NOT NULL default 'CHANGE',#gid smallint(5) unsigned NOT NULL default '90',#" vexim2/setup/mysql.sql sed -i -e "s#IDENTIFIED BY 'CHANGE';#IDENTIFIED BY '$VEXIMPASS';#" vexim2/setup/mysql.sql sed -i -e "s#CHANGE#$SITEADMINPASS#" vexim2/setup/mysql.sql sed -i -e "s#$1$12345678$2lQK5REWxaFyGz.p/dos3/#<somecrypt>#" vexim2/setup/mysql.sql mysql -uroot -p vexim < vexim2/setup/mysql.sql
sed -e "s#$sqlpass = \"CHANGE\";#$sqlpass = \"$VEXIMPASS\";#" vexim2/vexim/config/variables.php
VExim Exim Configs
cp vexim2/docs/configure /etc/exim/exim.conf cp vexim2/docs/vexim* /etc/exim
ClamAV Integration
sed -i -e "s%#LocalSocket /var/run/clamav/clamd.sock%LocalSocket /var/run/clamav/clamd.sock%" /etc/clamd.conf sed -i -e "s%TCPSocket 3310%#TCPSocket 3310%" /etc/clamd.conf service clamd restart sed -e "s#clamd:/var/run/clamav/clamd#clamd:/var/run/clamav/clamd.sock#" /etc/exim/exim.conf
sed -i -e "s#/usr/local/mailman#/var/lib/mailman#" /etc/exim/exim.conf
Edit your IP
MY_IP = CHANGE
sed -i -e "s#/tmp/mysql.sock#/var/lib/mysql/mysql.sock#" /etc/exim/exim.conf sed -i -e "s%exim_user = mailnull%#exim_user = mailnull%" /etc/exim/exim.conf sed -i -e "s%exim_group = mail%#exim_group = mail%" /etc/exim/exim.conf
Remove all references from exim.conf to mailnull and mail groups. Change mailman's group/user to mailman
user = mailnull group = mail
/var/www/html/vexim/config/variables.php
$mailroot = "/usr/local/mail/"; $mailmanroot = "http://www.EXAMPLE.com/mailman";
Change all references in /etc/exim/exim.conf of /usr/local/etc/ to /etc/
Courier-IMAP
Building Courier-Imap RPMS
wget http://easynews.dl.sourceforge.net/sourceforge/courier/courier-authlib-0.58.tar.bz2 wget http://easynews.dl.sourceforge.net/sourceforge/courier/courier-0.53.1.tar.bz2 mkdir $HOME/rpm $HOME/rpm/SOURCES $HOME/rpm/SPECS $HOME/rpm/BUILD $HOME/rpm/SRPMS $HOME/rpm/RPMS $HOME/rpm/RPMS/i386 echo "%_topdir $HOME/rpm" >> $HOME/.rpmmacros rpmbuild -ta courier-authlib-0.58.tar.bz2 su rpm -Uvh rpm/RPMS/i386/courier-authlib-0.58-1.i386.rpm rpm -Uvh rpm/RPMS/i386/courier-authlib-userdb-0.58-1.i386.rpm rpm -Uvh rpm/RPMS/i386/courier-authlib-devel-0.58-1.i386.rpm exit mv courier-0.51.0.tar.bz2 rpm/SOURCES/ tar -xvjf rpm/SOURCES/courier-0.51.0.tar.bz2 *courier.spec perl -pi -e "s#_unpackaged_files_terminate_build1#_unpackaged_files_terminate_build 0#" courier-0.51.0/courier.spec mv courier-0.51.0/courier.spec rpm/SPECS rmdir courier-0.51.0 rpmbuild -bb --without fax --without ldap rpm/SPECS/courier.spec cd $HOME/rpm/RPMS/i386 su rpm -Uvh courier-0*.rpm courier-imapd-0*.rpm courier-pop3d-0*.rpm exit
* We are going to be performing configuration for both IMAP and POP3
below. If you'd like to not run one of these two daemons, you can simply ignore the steps for its configuration file.
cd /etc/authlib vi authdaemonrc
Now, replace the following lines: Replace: authmodulelist="authuserdb authpam authpgsql authldap authmysql authcustom authpipe" with: authmodulelist="authmysql" Now create a file in that directory called authmysqlrc, with the cat >authmysqlrc <<EOF MYSQL_SERVER localhost MYSQL_USERNAME vexim MYSQL_PASSWORD change MYSQL_SOCKET /var/lib/mysql/mysql.sock MYSQL_PORT 3306 MYSQL_OPT 0 MYSQL_DATABASE vexim MYSQL_USER_TABLE users MYSQL_CRYPT_PWFIELD crypt MYSQL_UID_FIELD uid MYSQL_GID_FIELD gid MYSQL_LOGIN_FIELD username MYSQL_HOME_FIELD pop MYSQL_NAME_FIELD realname EOF chkconfig --add courier chkconfig --add courier-authlib service courier restart service courier-authlib restart
Squirrelmail
Mailman
References
http://silverwraith.com/vexim/