Setting Mail Server with Qmail on Fedora 3 part5
21. Installing Squirrelmail
# tar zxvf squirrelmail-1.4.4.tar.gz
# mv squirrelmail-1.4.4 /var/www/html/webmail
# mkdir /var/sqattachements
# chown -R apache:apache /var/sqattachements
# cd /var/www/html/webmail
# chown -R apache:apache data
# cd config
# ./conf.pl
General
-------
1. Domain : 1.2.3.4 (Enter the IP of your server here. Don't be an idiot and actually use 1.2.3.4)
2. Invert Time : false
3. Sendmail or SMTP : SMTP
IMAP Settings
--------------
4. IMAP Server : localhost
5. IMAP Port : 143
6. Authentication type : login
7. Secure IMAP (TLS) : false
8. Server software : other
9. Delimiter : detect
SMTP Settings
-------------
4. SMTP Server : localhost
5. SMTP Port : 25
6. POP before SMTP : false
7. SMTP Authentication : login
8. Secure SMTP (TLS) : false
try to open in your browser http://www.yourdomain.com/webmail
Username: postmaster@smiert.org
Password: your_password
# cd /var/www/html/webmail/plugins
# tar zxvf change_pass-2.7-1.4.x.tar.gz
# cd /var/www/html/webmail//config
# ./conf.pl
If user can login without typing domain, we can editting file src/redirect.php like this:
/* remove redundant spaces */
$login_username = trim($login_username).'@smiert.org';
The original like this ( before edited):
/* remove redundant spaces */
$login_username = trim($login_username);
22. Installing Clam Antivirus
# cd /downloads/qmailrocks/
# rpm -Uvh clamav-0.87-1.rpm
# rpm -Uvh clamav-devel-0.87-1.rpm
# vi /etc/clamd.conf
"Example" - should already be commented out. However, if it is not, make sure that it is commented out (#)
"LogFile" - should be set to /var/log/clamav/clamd.log
"LogTime" - should be uncommmented.
"LogSyslog" - should be uncommented.
"User" - should be set to qscand
"ScanMail" - should be uncommented.
# useradd -c "Qmail-Scanner Account" -s /bin/false qscand
# /etc/init.d/clamd stop
# /etc/init.d/clamd start
# /usr/bin/freshclam -l /var/log/clamav/clam-update.log
# crontab -e
25 1 * * * /usr/bin/freshclam --quiet -l /var/log/clamav/freshclam.log
23. Installing SpamAssassin
# cd /downloads/qmailrocks/perlmods/rpms/
# rpm -Uvh perl-Mail-SpamAssassin-3.0.2-1.i386.rpm
# cd /downloads/qmailrocks/
# rpm -Uvh spamassassin-3.0.2-1.i386.rpm spamassassin-tools-3.0.2-1.i386.rpm
# rpm -Uvh --nodeps spamassassin-3.0.2-1.i386.rpm spamassassin-tools-3.0.2-1.i386.rpm
# groupadd spamd
# useradd -g spamd -s /home/spamd spamd
# vi /etc/sysconfig/spamassassin
SPAMDOPTIONS="-x -u spamd -H /home/spamd -d"
# vi /etc/mail/spamassassin/local.cf
required_hits 5
# /etc/rc.d/init.d/spamassassin start
# ps aux | grep spamd
spamd 3734 0.2 2.0 24992 20808 ? S 14:21 0:01 /usr/bin/spamd -x -u spamd -H /home/spamd -d
# setup
One in the setup menu, scroll down and select the "system services" option. From the system services menu, scroll down to "clamd". Make sure that there is an asterisk (*) next to clamd, indicating it is set to start on boot. If no asterisk is present, press the spacebar to add it. Repeat the procedure for Spamassasin.
24. Installing QmailScanner with qms-analog
# cd /downloads/qmailrocks
# tar zxvf qmail-scanner-1.25.tgz
# tar zxvf qms-analog-0.4.2.tar.gz
# cd qms-analog-0.4.2
# make all
# cp qmail-scanner-1.25-st-qms-YYYYMMDD.patch /downloads/qmailrocks/qmail-scanner-1.25/
# cd /downloads/qmailrocks/qmail-scanner-1.25
# patch -p1 < qmail-scanner-1.25-st-qms-YYYYMMDD.patch
# cd /downloads/qmailrocks/qmail-scanner-1.25
# vi qms-config
#!/bin/sh
if [ "$1" != "install" ]; then
INSTALL=
else
INSTALL="--install"
fi
./configure --domain smiert.org \
--admin postmaster \
--local-domains "smiert.org" \
--add-dscr-hdrs yes \
--dscr-hdrs-text "X-Antivirus-MYDOMAIN" \
--ignore-eol-check yes \
--sa-quarantine 0 \
--sa-delete 0 \
--sa-reject no \
--sa-subject ":SPAM:" \
--sa-delta 0 \
--sa-alt yes \
--sa-debug no \
--notify admin \
"$INSTALL"
# chmod 755 qms-config
# ./qms-config
# ./qms-config install
# setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -z
# setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -z
# chown -R qscand:qscand /var/spool/qmailscan
# vi /var/qmail/supervise/qmail-smtpd/run
#!/bin/sh
QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl" ; export QMAILQUEUE
QMAILDUID=`id -u vpopmail`
NOFILESGID=`id -g vpopmail`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
exit 1
fi
exec /usr/local/bin/softlimit -m 40000000 \
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \
/var/qmail/bin/qmail-smtpd smiert.org \
/home/vpopmail/bin/vchkpw /usr/bin/true 2>&1
# qmailctl stop
# qmailctl start
# qmailctl stat
# cd /downloads/qmailrocks/qmail-scanner-1.25/contrib
# chmod 755 test_installation.sh
# ./test_installation.sh -doit
25. Installing QmailAnalog w/qlogtools & qms-analog
# cd /downloads/qmailrocks/
# tar zxvf qmailanalog-0.70.tar.gz
# cd qmailanalog-0.70
# patch < /downloads/qmailrocks/patches/0.70-errno.patch
# make && make setup check
# cd /downloads/qmailrocks/
# tar zxvf qlogtools-3.1.tar.gz
# cd qlogtools-3.1
# patch < /downloads/qmailrocks/patches/qlogtools_errno.patch
# mkdir /usr/local/man (if directory already exists, you're good to go)
# make
# ./installer
# cp /downloads/qmailrocks/qms-analog-0.4.2/qmailstats /var/qmail/bin
# vi /var/qmail/bin/qmailstats
#!/bin/sh
## qms-analog and qmailanalog invocation script
##
## Note: For better readability of the nightly stats email, set your email
## client font to a fixed width font - then all the columns line up
## very nicely.
##
PATH=/usr/local/qmailanalog/bin:/var/qmail/bin:/bin:/usr/bin:/usr/local/bin
QMAILSTATS="/tmp/q.$$"
EMAILMSG="/tmp/qms.$$"
umask 077
DATE=`date +'%D'`
## prepare qmail log entries for qmailanalog routines
cat /var/log/qmail/qmail-send/* /var/log/qmail/qmail-pop3d/* /var/log/qmail/qmail-smtpd/* | tai64n2tai | awk '{$1=substr($1,1,index($1,".")+6);print}' | matchup > $QMAILSTATS 5>/dev/null
## build the email message header
echo "To: postmaster@smiert,org" > $EMAILMSG
echo "From: postmaster@smiert.org" >> $EMAILMSG
echo "Subject: Nightly Qmail Stats Report for $DATE" >> $EMAILMSG
echo "" >> $EMAILMSG
echo "" >> $EMAILMSG
## qms-analog invocation
#
# USAGE: qms-analog hours-of-history
#
# hours-of-history (0 - n) hours of history to collect
# 0 => all records
# sort-key (optional) sort key for account statistics
# msgbw (default) msg bandwidth - successful msgs
# alpha alphanumeric by account name
# virus number of viruses received
# saavg Spamassassin avg score
# sadet Spamassassin msgs detected
#
# Examples:
# "qms-analog 24" - use only records within the last 24 hours,
# sort by msg bandwidth
# "qms-analog 168" - use only records within the last 7 days,
# sort by msg bandwidth
# "qms-analog 0" - use all records, sort by msg bandwidth
# "qms-analog 0 alpha" - use all records, sort alphabetically
# "qms-analog 0 saavg" - use all records, sort by Spam average score
#
# Note: Add or remove statistical time frames to suit your preference -
# "last 24 hours" and "all records" are uncommented below by default.
##
#### Last 24 hours
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $EMAILMSG
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ L a s t 2 4 H o u r s ~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $EMAILMSG
cat /var/spool/qmailscan/qms-events.log | qms-analog 24 >> $EMAILMSG
####
#### Last 7 days
#echo "" >> $EMAILMSG
#echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $EMAILMSG
#echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ L a s t 7 D a y s ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $EMAILMSG
#cat /var/spool/qmailscan/qms-events.log | qms-analog 168 >> $EMAILMSG
####
#### Last 30 days
#echo "" >> $EMAILMSG
#echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $EMAILMSG
#echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ L a s t 3 0 D a y s ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $EMAILMSG
#cat /var/spool/qmailscan/qms-events.log | qms-analog 5040 >> $EMAILMSG
####
#### All records in qms-events.log
echo "" >> $EMAILMSG
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $EMAILMSG
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ A l l R e c o r d s ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $EMAILMSG
cat /var/spool/qmailscan/qms-events.log | qms-analog 0 >> $EMAILMSG
####
## qmailanalog invocation
echo "" >> $EMAILMSG
echo "" >> $EMAILMSG
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $EMAILMSG
zoverall < $QMAILSTATS >> $EMAILMSG
echo "" >> $EMAILMSG
echo "" >> $EMAILMSG
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $EMAILMSG
zfailures < $QMAILSTATS >> $EMAILMSG
echo "" >> $EMAILMSG
echo "" >> $EMAILMSG
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >> $EMAILMSG
zdeferrals < $QMAILSTATS >> $EMAILMSG
echo "" >> $EMAILMSG
## pipe the message into qmail-inject
cat $EMAILMSG | qmail-inject
## delete temp files
rm -f $QMAILSTATS
rm -f $EMAILMSG
# chmod 750 /var/qmail/bin/qmailstats
# /var/qmail/bin/qmailstats
# crontab -e
0 3 * * * /var/qmail/bin/qmailstats 1>/dev/null 2>/dev/null