I have get the permission to copy paste this great guide and keep it updated. The Guide will soon come in a updated version on this homepage.
Link to the Original is online here: http://www.bowe.id.au/michael/isp/webmail-server.htm
INSTALL UCSPI-TCP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
cd /usr/local/src wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz wget http://www.qmail.org/ucspi-rss.diff wget http://djbware.csi.hu/patches/ucspi-tcp-0.88.errno.patch tar xzf ucspi-tcp-0.88.tar.gz chown -R root.root ucspi-tcp-0.88 cd ucspi-tcp-0.88 #Patch error so that it works with newer servers. patch < ../ucspi-tcp-0.88.errno.patch # Patch rblsmtpd so that it can be used with all the newer RBL zones. # This patch also lets you specify a custom error message to be returned to the sender. patch -p0 rblsmtpd.c < ../ucspi-rss.diff patch < ../ # Modify rblsmtpd.c to increase the maximum size of the error text that is allowed # to be returned to the sender from 200 to 500 chars. # This allows you to create some nice and descriptive text to send to people who # are being blocked by your RBL filters |
1 |
|
1 2 3 4 5 |
vi rblsmtpd.c go to line 166 and change it from if (text.len > 200) text.len = 200; to if (text.len > 500) text.len = 500; |
1 |
|
1 2 |
make make setup check |
INSTALL DAEMONTOOLS
1 2 3 4 5 6 7 8 9 10 11 |
cd /usr/local/src wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz wget http://djbware.csi.hu/patches/daemontools-0.76.errno.patch mkdir -p /package chmod 1755 /package cd /package tar xzfp /usr/local/src/daemontools-0.76.tar.gz cd admin patch daemontools-0.76/src/error.h < /usr/local/src/daemontools-0.76.errno.patch cd daemontools-0.76 package/install |
INSTALL QMAIL
Download the required files
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
cd /usr/local/src wget http://cr.yp.to/software/qmail-1.03.tar.gz wget http://qmail.jms1.net/patches/qmail-1.03-jms1-7.10.patch wget http://kennethdalbjerg.dk/files/qmailctl.txt </div> Create the users and groups required for qmail <div style="border: 1px solid #000000; white-space: pre-wrap; overflow: auto; padding: 8px;"> <pre>groupadd nofiles useradd -g nofiles -d /var/qmail qmaild useradd -g nofiles -d /var/qmail qmaill useradd -g nofiles -d /var/qmail qmailp useradd -g nofiles -d /var/qmail/alias alias groupadd qmail useradd -g qmail -d /var/qmail qmailq useradd -g qmail -d /var/qmail qmailr useradd -g qmail -d /var/qmail qmails |
Unzip the sources, apply the required patches, compile
1 2 3 4 |
tar xzf qmail-1.03.tar.gz mv qmail-1.03 qmail-1.03-jms1-7.10 cd qmail-1.03-jms1-7.10 patch < ../qmail-1.03-jms1-7.10.patch |
Edit qmail-smtpd.c and change the code on the straynewline function (around line 54) from 451 to 553
Without this you will get nasty loops forming when a remote servers sends you an message with invalid formatting. By default qmail will says something like “I am not going to accept that message at the moment, you can try again later”. However in my experience the sending server will try sending the same message again a few seconds later, and this will go around and around in a loop for days on end – consuming valuable bandwidth and resources. By changing the error code to 553, it is making the error be permanent ie “I am not going to accept that message, don’t try sending it again”
1 2 3 4 5 6 7 |
make make man If you are "upgrading" an existing qmail installation, you must shut down everything which has to do with qmail before typing this next command. This includes qmail-send, as well as any SMTP, IMAP, or POP3 services. make setup check ./config cd .. |
Remove the sendmail package, and link in qmail’s replacement utility
1 2 3 4 5 |
rm /usr/lib/sendmail rm /usr/sbin/sendmail # Link in qmail's replacement "sendmail-like" tools ln -s /var/qmail/bin/sendmail /usr/lib ln -s /var/qmail/bin/sendmail /usr/sbin |
The qmailctl script contains all the various commands that will allow us to control our qmail daemons. Put it in with the other qmail binaries. Also link it into /usr/bin so it will be in our “path” for easy access
1 2 |
cp /usr/local/src/qmailctl.txt /var/qmail/bin/qmailctl chmod 755 /var/qmail/bin/qmailctl |
1 |
ln -s /var/qmail/bin/qmailctl /usr/bin |
Setup the /etc/tcp.smtp file
This file controls who is allowed to send and/or relay mail on this server
An example configuration follows :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
#------------------------------------------------------ # DESCRIPTION OF THE RULES TO REMIND ME OF HOW THIS FILE WORKS # # If you set 'allow', this means that our mail server will allow # the specified IP range to make a TCP connection to our server # # If you set 'deny', this means that our mail server will not allow # the specified IP range to make a TCP connection to our server # # If you set RELAYCLIENT="", this means that the listed IP range is # allowed to relay mail through our server # # If you dont set RELAYCLIENT="", this means that the listed IP range # will not be able to relay mail through our server # # If you set RBLSMTPD="", this means that the listed IP ranges will # not be checked against any of the RBL databases # # If you set RBLSMTPD="some text here", this means that an RBL lookup # wont be performed, but the mail will be rejected with the specified # text as a 4xx temp error message # # If you set RBLSMTPD="-some text here", this means that an RBL lookup # wont be performed, but the mail will be rejected with the specified # text as a 5xx perm error message # # If you do not set RBLSMTPD="" or ="some text", then an RBL lookup # will be performed. If the lookup is successful, then RBLSMTPD will # return your custom error message (as specified in the -r parameter # in smtpd supervise script) # #----------------------------------------------------- # HERE ARE THE RULES! : #----------------------------------------------------- # BYPASS OPEN RELAY CHECKING FOR THESE IPS : # # These IPs are ones that we have setup so that they arent RBL checked. # We have done this because these particular servers are RBL listed, # and for whatever reason they can't/won't fix their open relay problem, # and we still want to be able to receive mail from them. # # reminder text goes here for this entry so we know the story... 111.111.111.111:allow,RBLSMTPD="" # reminder text goes here for this entry so we know the story... 222.222.222.222:allow,RBLSMTPD="" # #----------------------------------------------------------------- # DONT ALLOW THESE IPS TO SEND MAIL TO US : # # mailXX.offermail.net connecting regularly and sending invalid # format messages causing exit with status 256 (bare linefeed normally) # entry added 15/12/2001 # after looking at the mail coming from these servers it was found to be spam 216.242.75.100-116:allow,RBLSMTPD="-Connections from this IP have been banned." # # heaps of spam from replyto of *@freeamateurhotties.com dec2001 64.228.127.:allow,RBLSMTPD="-Connections refused due to spam from freeamateurhotties.com" 154.20.94.:allow,RBLSMTPD="-Connections refused due to spam from freeamateurhotties.com" 209.151.132.:allow,RBLSMTPD="-Connections refused due to spam from freeamateurhotties.com" 216.18.85.:allow,RBLSMTPD="-Connections refused due to spam from freeamateurhotties.com" # #----------------------------------------------------------------- # ALLOW THESE IPS TO RELAY MAIL THROUGH OUR SERVER # # Local class-c's from our LAN are allowed to relay, # and we wont bother doing any RBL checking. 123.123.123.:allow,RELAYCLIENT="",RBLSMTPD="" 123.111.111.:allow,RELAYCLIENT="",RBLSMTPD="" # # Connections from localhost are allowed to relay # (because the WebMail server runs on localhost), # and obviously there is no point trying to perform an RBL check. 127.0.0.1:allow,RELAYCLIENT="",RBLSMTPD="" # #----------------------------------------------------------------- # ALLOW EVERYONE ELSE TO SEND US MAIL # # Everyone else can make connections to our server, # but not allowed to relay # RBL lookups are performed :allow |
Setup the /etc/tcp.pop3 file
This file controls who is allowed to access the POP3 services on this server
An example configuration follows :
1 2 3 4 |
# Allow any client to connect to us via POP3 # If people are abusing POP3 such as denial-of-service on POP3, # you can add their ips here to block them out :allow |
Now we have created our tcp.smtp and tcp.pop3 files, we need to compile them into the cdb database format that the tcpserver program can read
1 |
qmailctl cdb |
Adjust various aspects of the qmail configuration to suite our tastes :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# use postmaster@<span style="color: #ff0066;">hostname.yourdomain.com </span>as sender in bounce messages # rather than the default MAILER-DAEMON@<span style="color: #ff0066;">hostname.yourdomain.com </span>echo 'postmaster' > /var/qmail/control/bouncefrom <br><br> # Define how to handle "double bounces". # The server admin has two choices here, either to receive double bounces # or to discard them. If your server doesn't handle a lot of mail then it # wouldn't hurt to receive all double bounces for the admin's inspection. # But if your server handles a lot of mail, then it is more likely that you # are going to want to discard double-bounces, because you will end up with # potentially thousands of these every day. # # If you want to keep double-bounces, use these commands to nominate what # email address to send them through to (eg doublebounce@<span style="color: #ff0066;">yourdomain.com) </span>: echo 'doublebounce' > /var/qmail/control/doublebounceto echo '<span style="color: #ff0066;">yourdomain.com</span>' > /var/qmail/control/doublebouncehost # (dont forget that you will need to make sure you have created a mailbox # to receive these mails. You could use qmailadmin to create a dedicated # mailbox, or perhaps setup an alias on an existing mailbox) # # Or if you would prefer to silently discard any doublebounces, # then use these commands instead echo 'doublebounce' > /var/qmail/control/doublebounceto echo '<span style="color: #ff0066;">hostname.yourdomain.com</span>' > /var/qmail/control/doublebouncehost echo '#' > ~alias/.qmail-doublebounce chmod 644 ~alias/.qmail-doublebounce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# set maximum message size to be 8Mb echo '8000000' > /var/qmail/control/databytes <br><br> # queue mail for up to 4 days echo '345600' > /var/qmail/control/queuelifetime <br><br> # Populate badmailto so that mail with invalid address formatting gets rejected echo '# reject containing invalid characters, brackets or multiple @' > /var/qmail/control/badmailto echo '[!%#:\*\^]' >> /var/qmail/control/badmailto echo '[\(\)]' >> /var/qmail/control/badmailto echo '[\{\}]' >> /var/qmail/control/badmailto echo '@.*@' >> /var/qmail/control/badmailto <br><br> # setup the default domain for use where an address does not have a domain specified echo '<span style="color: #ff0066;">yourdomain.com</span>' > /var/qmail/control/defaultdomain <br><br> # Note, this following command is optional! # # If you want qmail to send all outbound mail via a particular mail server # rather than to send it direct to the recipient's mail server, then this # can be achieved with the smtproutes command. # # SEND ALL OUTBOUND MAIL VIA SMARTHOST echo ':<span style="color: #ff0066;">yoursmarthost.yourdomain.com</span>' > /var/qmail/control/smtproutes <br><br> # redirect any mail sent to root@<span style="color: #ff0066;"><strong>hostname</strong>.yourdomain.com </span>to 'postmaster@<span style="color: #ff0066;">yourdomain.com</span> # redirect any mail sent to postmaster@<span style="color: #ff0066;"><strong>hostname</strong>.yourdomain.com </span>to 'postmaster@<span style="color: #ff0066;">yourdomain.com</span> # redirect any mail sent to mailer-daemon@<span style="color: #ff0066;"><strong>hostname</strong>.yourdomain.com </span>to 'postmaster@<span style="color: #ff0066;">yourdomain.com</span> echo 'postmaster@<span style="color: #ff0066;">yourdomain.com</span>' > ~alias/.qmail-root echo 'postmaster@<span style="color: #ff0066;">yourdomain.com</span>' > ~alias/.qmail-postmaster echo 'postmaster@<span style="color: #ff0066;">yourdomain.com</span>' > ~alias/.qmail-mailer-daemon chmod 644 ~alias/.qmail-* |
Create / configure the various qmail run scripts :
1 2 3 4 5 6 7 8 9 |
cd /etc/rc.d/init.d ln -s /var/qmail/bin/qmailctl /etc/rc.d/init.d/qmail ln -s ../init.d/qmail /etc/rc.d/rc0.d/K30qmail ln -s ../init.d/qmail /etc/rc.d/rc1.d/K30qmail ln -s ../init.d/qmail /etc/rc.d/rc2.d/S80qmail ln -s ../init.d/qmail /etc/rc.d/rc3.d/S80qmail ln -s ../init.d/qmail /etc/rc.d/rc4.d/S80qmail ln -s ../init.d/qmail /etc/rc.d/rc5.d/S80qmail ln -s ../init.d/qmail /etc/rc.d/rc6.d/K30qmail |
1 2 3 4 5 6 |
mkdir -p /var/qmail/supervise/qmail-send/log mkdir -p /var/qmail/supervise/qmail-smtpd/log mkdir -p /var/qmail/supervise/qmail-pop3d/log chmod +t /var/qmail/supervise/qmail-send chmod +t /var/qmail/supervise/qmail-smtpd chmod +t /var/qmail/supervise/qmail-pop3d |
1 |
vi /var/qmail/supervise/qmail-send/run |
1 2 |
#!/bin/sh exec env - PATH="/var/qmail/bin:$PATH" qmail-start ./Maildir/ |
1 |
vi /var/qmail/supervise/qmail-send/log/run |
1 2 3 4 5 6 |
#!/bin/sh # Keep 30 logs of max 10Mb each # # They will get rotated when they reach 10Mb in size, # or at midnight when our crontab script fires (whichever event comes 1st) exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t s10000000 n30 /var/log/qmail/send |
wget http://qmail.jms1.net/scripts/service-qmail-smtpd-run
mv service-qmail-smtpd-run run
Change run script so it fits yours setup
1 |
vi /var/qmail/supervise/qmail-smtpd/log/run |
1 2 3 4 5 6 |
#!/bin/sh # Keep 30 logs of max 10Mb each # # They will get rotated when they reach 10Mb in size, # or at midnight when our crontab script fires (whichever event comes 1st) exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t s10000000 n30 /var/log/qmail/smtpd |
1 |
vi /var/qmail/supervise/qmail-pop3d/run |
1 2 3 4 5 6 7 |
#!/bin/sh exec /usr/local/bin/softlimit -m 6000000 \ /usr/local/bin/tcpserver \ -H -l <span style="color: #ff0066;">hostname.yourdomain.com</span> \ -v -x /etc/tcp.pop3.cdb -c 30 -R 0 pop3 \ /var/qmail/bin/qmail-popup <span style="color: #ff0066;">hostname.yourdomain.com</span> \ /home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir 2>&1 |
1 2 3 4 5 6 7 8 9 |
# The line in orange should be used if you are running qmail on a computer # that is on a LAN that is using fake ips/masquerading. # It tells tcpserver not to bother trying to resolve ip addresses # to names when writing the POP3 log files. Usually with fake ips, # you cant resolve them to names, so it will make the POP3 services run # really slowly if it is always trying to resolve these addresses. # Alternatively, if you are eg an ISP and all your POP3 clients are # connecting from real IPs with resolvable names, then you can omit # the orange line and then then benefit from more readable logfiles. |
1 |
vi /var/qmail/supervise/qmail-pop3d/log/run |
1 2 3 4 5 |
#!/bin/sh # Keep 30 logs of max 10Mb each # They will get rotated when they reach 10Mb in size, # or at midnight when our crontab script fires (whichever event comes 1st) exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t s10000000 n30 /var/log/qmail/pop3d |
1 2 3 4 5 6 |
chmod 755 /var/qmail/supervise/qmail-send/run chmod 755 /var/qmail/supervise/qmail-send/log/run chmod 755 /var/qmail/supervise/qmail-smtpd/run chmod 755 /var/qmail/supervise/qmail-smtpd/log/run chmod 755 /var/qmail/supervise/qmail-pop3d/run chmod 755 /var/qmail/supervise/qmail-pop3d/log/run |
1 2 3 4 |
mkdir /var/log/qmail mkdir /var/log/qmail/smtpd mkdir /var/log/qmail/send mkdir /var/log/qmail/pop3d |
1 |
chown -R qmaill /var/log/qmail |
1 |
crontab -e |
1 2 3 4 |
# the following 3 lines rotate the qmail log files daily 0 0 * * * /usr/local/bin/svc -a /service/qmail-smtpd/log 0 0 * * * /usr/local/bin/svc -a /service/qmail-send/log 0 0 * * * /usr/local/bin/svc -a /service/qmail-pop3d/log |
1 2 3 |
ln -s /var/qmail/supervise/qmail-send /service ln -s /var/qmail/supervise/qmail-smtpd /service ln -s /var/qmail/supervise/qmail-pop3d /service |
At this point the qmail daemons should be running. A good way to verify this is to use this command :
1 |
ps axf |
If all is well, you should be able to see something like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
1218 ? S 0:00 /bin/sh /command/svscanboot 1222 ? S 0:00 \_ svscan /service 1224 ? S 0:00 | \_ supervise <strong>qmail-send</strong> 1230 ? S 0:00 | | \_ qmail-send 1236 ? S 0:00 | | \_ qmail-lspawn ./Maildir/ 1237 ? S 0:00 | | \_ qmail-rspawn 1238 ? S 0:00 | | \_ qmail-clean 1225 ? S 0:00 | \_ supervise log 1233 ? S 0:00 | | \_ /usr/local/bin/multilog t s10000000 n30 /var/log/qmail/send 1226 ? S 0:00 | \_ supervise <strong>qmail-smtpd</strong> 1231 ? S 0:00 | | \_ /usr/local/bin/tcpserver -v -x /etc/tcp.smtp.cdb -c 20 -R -u 504 -g 503 0 smtp /var/qmail/bin 1227 ? S 0:00 | \_ supervise log 1234 ? S 0:00 | | \_ /usr/local/bin/multilog t s10000000 n30 /var/log/qmail/smtpd 1228 ? S 0:00 | \_ supervise <strong>qmail-pop3d</strong> 1232 ? S 0:00 | | \_ /usr/local/bin/tcpserver -v -x /etc/tcp.pop3.cdb -c 30 -H -R 0 110 /var/qmail/bin/qmail-popup 1229 ? S 0:00 | \_ supervise log 1235 ? S 0:00 | \_ /usr/local/bin/multilog t s10000000 n30 /var/log/qmail/pop3d 1223 ? S 0:00 \_ readproctitle service errors: ....................................................................... |
Note the 3 qmail daemons : qmail-send, qmail-smtpd, qmail-pop3d, as well as their associated logging processes. If there is anything wrong with your install, an error message will generally be visible on the “readproctitle” line
You can control the qmail daemons by using the qmailctl program. You can just type that command without any parameters and it will display the available options eg start, stop, status, doqueue
VPOPMAIL
https://sourceforge.net/projects/vpopmail
Make the user accounts
1 2 3 4 |
# If you are using RH8.0, you will probably need to run this following command, # because RH8.0 comes preconfigured with UID/GID 89 allocated to postfix # # userdel postfix |
1 2 |
groupadd -g 89 vchkpw useradd -g vchkpw -u 89 -d /home/vpopmail vpopmail |
1 2 3 4 |
# We recommend you use the user and group id's of 89. The FreeBSD folks # have reserved 89 for the group and 89 for the user for vpopmail. Feel # free to have the OS assign the group/user id (for example, Solaris won't # allow gid 89). |
Download and unpack the source
1 2 3 4 5 6 |
cd /usr/local/src wget http://downloads.sourceforge.net/project/vpopmail/vpopmail-stable/5.4.33/vpopmail-5.4.33.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fvpopmail%2F&ts=1383645710&use_mirror=freefr mv vpopmail-5.4.33.tar.gz\?r\=http\:%2F%2Fsourceforge.net%2Fprojects%2Fvpopmail%2F vpopmail-5.4.33.tar.gz tar xzf vpopmail-5.4.33.tar.gz chown -R root.root vpopmail-5.4.33 cd vpopmail-5.4.33 |
Setup the MySQL support in the vpopmail sources
1 2 3 4 5 6 7 8 9 10 11 12 |
# Create the configuration file that vpopmail will use # to setup the connection to the mysql database # # This example will tell vpopmail : # * Log into the server running on localhost # * Use the default mysql port # (In fact if the server is localhost, and you don't specify a port number, then # I believe the that communications are done via unix sockets rather than TCP/IP) # * Login with username <em>vpopmailuser</em> # * Login with password <em>vpoppasswd</em> # * Use the database called vpopmail # |
1 2 3 4 5 |
mkdir ~vpopmail/etc chown vpopmail.vchkpw ~vpopmail/etc echo "localhost|0|<em>vpopmailuser</em>|<em>vpoppasswd</em>|vpopmail" > ~vpopmail/etc/vpopmail.mysql chown vpopmail.vchkpw ~vpopmail/etc/vpopmail.mysql chmod 640 ~vpopmail/etc/vpopmail.mysql |
1 2 3 |
# log into MySQL as the MySQL root user # and then create the database for vpopmail to use # and then setup the appropriate permissions on this database |
1 |
/usr/local/mysql/bin/mysql --password="<em>mysql-root-pwd</em>" |
1 |
CREATE DATABASE vpopmail; |
1 2 |
GRANT select,insert,update,delete,create,drop ON vpopmail.* TO <em>vpopmailuser</em>@localhost IDENTIFIED BY '<em>vpoppasswd</em>'; |
1 |
quit |
Now, build the program
|
|
1 2 |
make make install-strip |
Notes :
The “–enable-mysql-limits” configuration option is fairly new. I plan to update my guide to use this function at some point in the near future once I have done some testing etc of this functionality
I used to recommend the –disable-many-domains switch – which tells vpopmail to create one MySQL table per email domain. When I first started building vpopmail servers, I found this to be the most logical way, having each domain in its own table. However there has been some discussion about this config option on the vpopmail mailing lists, and it sound like this option may be removed at some point in the future. If you have a lot of domains on your server, having each domain in its own table can hurt performance. I now agree that –enable-many-domains (which is the default) is probably the better choice
Review the contents of the file is used to set the default limits for any domains / mailboxes in the vpopmail system. Make sure it contains reasonable defaults for your system.
1 |
vi ~vpopmail/etc/vlimits.default |
1 2 |
# in particular set the default mailbox size to be something reasonable eg 20Mb default_quota 20971520 |
Optionally, nominate a “default domain”. Users in this domain can login to POP3 etc using just their username. Users from all other domains need to use their full email address as their login name.
1 |
echo "<span style="color: #ff0066;">yourdomain.com</span>" > /home/vpopmail/etc/defaultdomain |
Setup the quota warning message that is sent to users when they are at 90% quota
1 |
vi quotawarn.msg |
123456789101112131415161718 <em>From: SomeCompany Postmaster <postmaster@<span style="color: #ff0066;">yourdomain.com</span>>Reply-To: postmaster@<span style="color: #ff0066;">yourdomain.com</span>To: SomeCompany User:;Subject: Mail quota warningMime-Version: 1.0Content-Type: text/plain; charset=iso-8859-1Content-Transfer-Encoding: 7bitYour mailbox on the server is now more than 90% full.So that you can continue to receive mail,you need to remove some messages from your mailbox.If you require assistance with this,please contact our support department :email : support@<span style="color: #ff0066;">yourdomain.com</span>Tel : xx xxxx xxxx</em>
1 |
cp quotawarn.msg /home/vpopmail/domains/.quotawarn.msg |
If you want, you can alter the standard message that gets sent to the sender in an overquota situation
1 |
echo "Message rejected. Not enough storage space in user's mailbox to accept message." > /home/vpopmail/domains/.over-quota.msg |
OK, vpopmail is now installed!
Some example vpopmail commands :
To add a domain :
1 2 |
/home/vpopmail/bin/vadddomain <span style="color: #ff0066;">yourdomain.com</span> yourpassword # this creates the domain and makes a mailbox postmaster@<span style="color: #ff0066;">yourdomain.com</span> |
To add a mailbox:
1 |
/home/vpopmail/bin/vadduser someone@<span style="color: #ff0066;">yourdomain.com</span> apassword |
(Or you can do it via qmailadmin)
To remove a mailbox
1 |
/home/vpopmail/bin/vdeluser someone@<span style="color: #ff0066;">yourdomain.com</span> |
(Or you can do it via qmailadmin)
To remove a domain :
1 |
/home/vpopmail/bin/vdeldomain <span style="color: #ff0066;">yourdomain.com</span> |
To change a user’s password
1 |
/home/vpopmail/bin/vpasswd someone@<span style="color: #ff0066;">yourdomain.com</span> newpassword |
(Or you can do it via qmailadmin)
To lookup info about a user
1 |
/home/vpopmail/bin/vuserinfo someone@<span style="color: #ff0066;">yourdomain.com</span> |
This gives you info such as name, crypted password, cleartext password, dir, quota, usage%, last auth.
It has a number of flags to let you see the individual fields, or you can see them all if you dont use any flags.
It also creates the maildirsize file in the users dir
Logging in via POP3
When your users are setting up their POP3 email clients (eg Outlook Express), they should use settings like this :
My incoming mail server is a POP3 server
Incoming mail server (POP3): pop3.yourdomain.com
Outgoing mail server (SMTP): smtp.yourdomain.com
POP3 account name : theirusername@yourdomain.com
Password: theirpassword
When you configured vpopmail, you had the opportunity to nominate a “default” domain. When users from the default domain authenticate, it is optional for them to add the @yourdomain.com onto the end of their username. If vpopmail sees that no domain has been specified by the user, then it will automatically perform the auth against the nominated default domain. If you are hosting multiple domains, then everyone who is NOT in the default domain MUST add their domain name onto the end of their username. (A small percentage of email programs eg Netscape Mail v4.7 do not permit the use of the @ symbol in account name. In this case you can use the % symbol instead of the @ symbol)
vpopmail roaming users :
With qmail, the typical way to control mail relaying is to put a list of rules into a file called tcp.smtp. The tcprules program is then used to compile this file into cdb database format with the output being stored in a file called tcp.smtp.cdb. The tcpserver program is configured (using the -x parameter) to read this file and thus know which SMTP clients are permitted to relay mail.
This type of configuration works well if there is a known range of IP addresses that are permitted to relay mail. eg the IP’s on the qmail server’s local LAN. However if the qmail server needs to provide outbound SMTP services for clients who may be connecting from any IP, you are going to run into problems. What is needed is some way to automate the process of granting users the ability to relay mail, without opening up access to all and sundry on the Internet.
vpopmail includes a solution for this problem. The solution is known as “roaming users” and is typically implemented with a technique known as “POP-before-SMTP”. Once a client has successfully authenticated via POP3, vpopmail will add the client’s IP to a list. vpopmail then merges this list with the contents of the tcp.smtp file and runs the tcprules program to compile a new version of the tcp.smtp.cdb file. Thus the client can now relay mail.
In addition to storing the client’s IP address, vpopmail will also store the time of authentication. The postmaster uses a cronjob on the qmail server to periodically (eg once per hour) run the clearopensmtp program. This program scans through the list of roaming clients and removes any entries that exceed the nominated age (eg 3 hours). This ensures that the list of IPs does not grow out of bounds, and that the roaming IPs are closed within a reasonable timeframe after being opened.
configure options for vpopmail that relate to roaming users :
1 2 3 4 5 |
./configure \ --enable-roaming-users \ <- enable roaming users functionality --enable-tcprules-prog=path \ <- defaults to /usr/local/bin/tcprules --enable-tcpserver-file=path \ <- defaults to /home/vpopmail/etc/tcp.smtp --enable-relay-clear-minutes=minutes <- defaults to 180 |
Example /var/qmail/supervise/qmail-smtpd/run file :
1 2 3 4 5 6 7 8 9 |
#!/bin/sh QMAILDUID=`id -u qmaild` NOFILESGID=`id -g qmaild` exec /usr/local/bin/softlimit -m 2000000 \ /usr/local/bin/tcpserver -v <strong>-x /home/vpopmail/etc/tcp.smtp.cdb</strong> -c 40 -R \ -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \ /usr/local/bin/rblsmtpd -b -C -r list.dsbl.org \ -t 5 \ /var/qmail/bin/qmail-smtpd 2>&1 |
Notes :
qmail servers are typically built with the tcp.smtp files being located in the /etc directory. This is not usually suitable for vpopmail roaming users, since the /etc directory will (should) not have write permissions for the vpopmail user. Therefore it is not going to be possible for vpopmail to write out updated versions of the tcp.smtp.cdb file. For use with roaming users, it is recommended that the tcp.smtp files are stored in ~vpopmail/etc
If a user auths, and their IP already exists in the roaming IP list, the timestamp for the entry is updated, but the tcprules program is not run. There is no need to rebuild the tcp.smtp.cdb file as the IP address is already permitted to relay. Rebuilding the file will only waste disk and CPU time.
If the vpopmail server is using the default cdb authentication backend, then the list of roaming IPs will be stored in a file called ~vpopmail/etc/open-smtp. If the vpopmail server is using the MySQL backend, the roaming IPs will be stored in a database table called relay. The SQL backend will give better performance on a busy server. Either way though, you should be cautious about enabling roaming user functionality on a very busy server, as a large amount of disk and CPU will be used with the continual rebuilding of the tcp.smtp.cdb file. If the server is busy enough you could run into nasty file locking issues which will cause vpopmail password authentication to intermittently fail. If you absolutely must have POP-before-SMTP functionality on your busy server, then there are only two possible solutions that I can think of : 1) you could try putting the tcp.smtp files onto a RAM disk, or 2) use vpopmail’s MySQL auth backend plus use Matt Simerson’s tcpserver patch that allows all of the tcp.smtp files to be stored in MySQL
For POP-before-SMTP to work, the POP3 daemon will need to run under the tcpserver program. This is because vpopmail uses tcpserver’s TCPREMOTEIP environment variable to work out what IP address the POP3 user is connecting from.
Over time POP-before-SMTP is becoming a less favored way of allowing roaming users to relay mail. SMTP-Auth appears to becoming the more preferred option, as it scales much more easily on a busy server. However for a small to medium sized server, POP-before-SMTP is still quite a workable option. If you would like investigate the use of SMTP-Auth take a look at this patch http://www.fehcom.de/qmail/smtpauth.html#PATCHES
IMAP-before-SMTP is possible when using Courier-IMAP v3.x. However it only works when configured “–with-authvchkpw –without-authdaemon”. When running –without-authdaemon, Courier-IMAP’s authvchkpw code is able to make use of vpopmail’s roaming user functions to allow IMAP-before-SMTP functionality. IMAP-before-SMTP is not possible when Courier-IMAP has been complied –with-authdaemon, because in this mode the user’s IP address is not made available to the authvchkpw code (via the TCPREMOTEIP env var). Also note that in Courier-IMAP v4.x and later, –without-authdaemon functionality is no longer available thus preventing IMAP-before-SMTP from working.
AUTORESPONDER
Current development location : http://www.sourceforge.net/projects/qmailadmin
This package is a prerequisite for qmailadmin.
Download and unpack the source
12345 cd /usr/local/srcwget <a href="http://optusnet.dl.sourceforge.net/sourceforge/qmailadmin/autorespond-2.0.4.tar.gz">http://optusnet.dl.sourceforge.net/sourceforge/qmailadmin/autorespond-2.0.4.tar.gz</a>tar xzf autorespond-2.0.4.tar.gzchown -R root.root autorespond-2.0.4cd autorespond-2.0.4
Build the program
12 makemake install
Notes :
Qmailadmin uses the autorespond program for both autoresponse (“mail robot” in qmailadmin-speak), and vacation response duties. However this is pretty badly FUBAR. Reason being is the autorespond.c is written to do duties as an autoresponse program only. “Out of the box” it doesn’t behave correctly when doing vacation response duties. The code inside the program can be easily tweaked to work correctly as a vacation responder, but this will break the autoresponder functionality. Unfortunately the settings are mutually exclusive. In my opinion the correct solution is to create two variations of this program, autorespond.c and vacation.c, install them both, and then tweak qmailadmin to call the right binary for the right job. I have opened a bug report on the qmailadmin sourceforge site to try and get this problem sorted out. If you read back through the qmailadmin and vpopmail archives, you will see the the autoresponder stuff is an ongoing saga 🙁
ps. Inter7 have got a modified version of the autorespond program, which I believe has been coded to work correctly as a vacation responder http://inter7.com/devel/autorespond-2.0.5.tar.gz
EZMLM / EZMLM-IDX
This package is a prerequisite for qmailadmin
ezmlm is mailing list software written by the author of qmail
ezmlm-idx is patch that adds extra features to the standard ezmlm program.
EZMLM : http://cr.yp.to/ezmlm.html
EZMLM-IDX PATCH : http://www.ezmlm.org
(although I often find this site unresponsive, and so I use one of the mirrors instead like http://www.glasswings.com.au/ezmlm/)
Download and unpack the ezmlm sources
1234 cd /usr/local/srcwget <a href="http://cr.yp.to/software/ezmlm-0.53.tar.gz">http://cr.yp.to/software/ezmlm-0.53.tar.gz</a>tar xzf ezmlm-0.53.tar.gzchown -R root.root ezmlm-0.53
123 wget <a href="http://www.bowe.id.au/michael/ftp/Sources/Linux/WebMail/ezmlm-idx-0.40.tar.gz">http://www.bowe.id.au/michael/ftp/Sources/Linux/WebMail/ezmlm-idx-0.40.tar.gz</a>tar xzf ezmlm-idx-0.40.tar.gzchown -R root.root ezmlm-idx-0.40
Merge the sources together
12 cp -R ezmlm-idx-0.40/* ezmlm-0.53/# (you need to press y quite a few times to allow the patch files to overwrite the original files)
12 cd ezmlm-0.53patch < idx.patch
Build the program
123 makemake manmake setup
QMAILADMIN
Original Authors : http://www.inter7.com/qmailadmin
Current Development location : https://sourceforge.net/projects/qmailadmin/
Description :
The domain postmaster can use this tool to view all the accounts on the domain as well as add/remove accounts, forwards, auto-responders etc.
Domains users can use this tool to modify their own user settings only. ie mailbox password, real name, forwards, vacations.
This tool does not let you create new domains.
Download and unpack the source
12345 cd /usr/local/srcwget <a href="http://optusnet.dl.sourceforge.net/sourceforge/qmailadmin/qmailadmin-1.2.9.tar.gz">http://optusnet.dl.sourceforge.net/sourceforge/qmailadmin/qmailadmin-1.2.9.tar.gz</a>tar xzf qmailadmin-1.2.9.tar.gzchown -R root.root qmailadmin-1.2.9cd qmailadmin-1.2.9
(Optional) Make a small mod that affects the look of the qmailadmin login page
edit the lang/en file, and change record 112 “Username” rather than “User Account”
(We found our users knew what to type as their “Username”, but didn’t know what to type as a “User Account”)
Build the program
12345678 ./configure \--enable-htmldir=/usr/local/apache/htdocs \--enable-cgibindir=/usr/local/apache/cgi-bin \--enable-maxusersperpage=12 \--enable-maxaliasesperpage=12 \--disable-modify-quota \--disable-ezmlm-mysql \--disable-help
12 # note, I chose to have 12 accounts per page in the config above,# because this makes these particular screens fit nicely on my 1024*768 monitor
12 makemake install-strip
Test to see if it works
1 http://webmail.<span style="color: #ff0066;">yourdomain.com</span>/cgi-bin/qmailadminIf you login a domain postmaster, then you should get the screens where you can view all and add/remove mailboxes, aliases, mailinglists etc on the domain. etc
If you login as a user, you can only access your own mailbox settings (eg password, forwards, vacation messages)
Setting limits :
You can setup limits on any domains where required by putting a .qmailadmin-limits file into the domain’s virtual dir (/home/vpopmail/domains/yourdomain.com). Make sure vpopmail user has read permissions for this file.
Syntax of .qmailadmin-limits file is as follows :
1234 maxpopaccounts Xmaxforwards Xmaxmailinglists Xmaxautoresponders X
Set X to be the maximum desired number for that feature
Set X to be 0 if you want to disable that feature & menu itemThere are also some other settings that can be specified in the .qmailadmin-limits file, refer to section 6 of the qmailadmin installation instructions (http://inter7.com/qmailadmin/install.txt) for more info
A bit of a long-winded misc note to myself :
(If you are setting up your vpopmail server for the first time, then this block of text has no relevance to you. You can skip straight past this waffle and go onto the next section…)
As of qmailadmin-1.0.21, you cant create “aliases” any more. What qmailadmin previously created as aliases, are now created as forwards. Aliases dump incoming mail for that aliased address directly into the recipient user’s Maildir. The problem with this is it bypassed any further “.qmail” processing, meaning that you ran into problems if you were trying to setup some of the more fancy things (like per-user SpamAssassin configurations?). Using forwards bypasses this problem as the message will get re-injected back into the queue for delivery.
However this change does cause some problems for sites that already have existing aliases in use. The problem is that when you go into qmailadmin-1.0.21 and select the forwards screen, all the existing aliases and forwards for that domain are displayed.
Problem # 1 : For mail that is being redirected to a local account, you can’t tell from this screen whether the user is getting alias or forward delivery. If you were trying to setup some tricky per-user stuff, then you are going to get variable results because some users may be configured as alias, and others are configured as forward, but you cant easily tell which is which from this screen
Problem # 2 : Up the top there is a count showing “[Used # / limit]”. This count relates to the number of forwards in use and the maxforwards qmailadmin-limits setting. The count ignores any existing aliases. This could potentially cause confusion for domain postmasters as you will be looking at a screen full of accounts and if some of them have been previously setup as aliases then it is going to be hard to reconcile the reported count against the number of accounts displayed on the screen
What is needed is some sort of utility that will scan and find existing aliases and convert them over to the now-preferred forward syntax…. That would keep the delivery method consistent for all users, and would also eliminate any problems with the qmailadmin-limits code
Note: As of qmailadmin-1.0.25, there is a tool for converting existing aliases to forwards. Look in the contrib dir for the tools called alias2forward.pl
qmailadmin v1.2.1 and later store aliases and autoresponders in valias table if vpopmail was compiled with –enable-valias. If you are upgrading from a previous version of QmailAdmin and used the –enable-valias option when building vpopmail, be sure to download vpopmail 5.4.1 or later and use the dotqmail2valias program to convert .qmail-alias files to valias table entries.
COURIER IMAP
http://www.courier-mta.org/imap/
Courier-IMAP is an IMAP server. Having an IMAP server is a prerequisite to be able run a IMAP-client WebMail system like SquirrelMail. Courier-IMAP is good choice because it has support for vpopmail authentication and maildir mailboxes.
Download and unpack the authentication library
123456 cd /usr/local/srcwget <a href="http://optusnet.dl.sourceforge.net/sourceforge/courier/courier-authlib-0.58.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/courier/courier-authlib-0.58.tar.bz2</a>bunzip2 courier-authlib-0.58.tar.bz2tar xf courier-authlib-0.58.tarchown -R root.root courier-authlib-0.58cd courier-authlib-0.58
Build the authentication library
1234567891011121314 ./configure \--prefix=/usr/local/courier-authlib \--without-authpam \--without-authldap \--without-authpwd \--without-authmysql \--without-authpgsql \--without-authshadow \--without-authuserdb \--without-authcustom \--without-authcram \--without-authpipe \--with-authdaemon \--with-authvchkpw
123 # note, if you are running redhat/fedora, you may have to add a# --with-redhat# to the list of configuration settings above
123 makemake installmake install-configure
Review the settings for the authentication library
1 vi /usr/local/courier-authlib/etc/authlib/authdaemonrc
1 authmodulelist="authvchkpw"
1 <-- Authenticate via vpopmail
Configure the authentication library so it is running all the time from bootup onwards
12 <span style="font-family: Courier New;">cp courier-authlib.sysvinit /etc/rc.d/init.d/courier-authlibchmod 744 /etc/rc.d/init.d/courier-authlib</span>
1 chkconfig --add courier-authlibThen I like to use the ntsysv program to double-check that courier-authlib is set to launch at boot time
If you aren’t ready to reboot the server now, you can fire up the authentication libraries in the mean time with this command :
1 /etc/rc.d/init.d/courier-authlib start
At this point the courier-authlib software should be running. A good way to verify this is to use this command :
1 ps axf
And if all is well, you should be able to see something like this :
1234567 23689 ? S 0:00 /usr/local/courier-authlib/sbin/courierlogger -pid=/usr/local/courier-authlib/var/spool/23690 ? S 0:00 \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond23702 ? S 0:00 \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond23703 ? S 0:00 \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond23704 ? S 0:00 \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond23705 ? S 0:00 \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond23706 ? S 0:00 \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
FAM + Courier-IMAP on Redhat 7.3 doesnt seem very stable. On old Linux platforms, I would recommend you remove FAM before trying to install Courier-IMAP ( By the way, the alternative/replacement package GAMIN seems to works OK with Courier-IMAP on newer platforms like FC4/FC5/CentOS43)
1 rpm -e fam fam-devel
Download and unpack the courier-IMAP source
123456 cd /usr/local/srcwget <a href="http://optusnet.dl.sourceforge.net/sourceforge/courier/courier-imap-4.1.1.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/courier/courier-imap-4.1.1.tar.bz2</a>bunzip2 courier-imap-4.1.1.tar.bz2tar xf courier-imap-4.1.1.tarchown -R root.root courier-imap-4.1.1cd courier-imap-4.1.1
Build the program
123456 COURIERAUTHCONFIG=/usr/local/courier-authlib/bin/courierauthconfig \CPPFLAGS=-I/usr/local/courier-authlib/include \./configure \--prefix=/usr/local/courier-imap \--disable-root-check \--with-ssl
123 # note, if you are running redhat/fedora, you may have to add a# --with-redhat# to the list of configuration settings above
123 makemake installmake install-configure
The Courier-IMAP package includes 4 servers that can be individually enabled/disabled : IMAP, IMAP-SSL, POP3, POP3SSL. In this example, we are only using the IMAP server.
1 vi /usr/local/courier-imap/etc/imapd
1234 MAXDAEMONS=40MAXPERIP=40IMAP_EMPTYTRASH=Trash:7,Sent:30IMAPDSTART=YES
1234 <-- Max number of IMAP daemons<-- All connections will be coming from single IP (SquirrelMail on localhost)<-- Enable automatic purging of mail from these folders<-- allow our init.d script (below) to boot up the imapd
Configure Courier-IMAP so it is running all the time from bootup onwards
12 <span style="font-family: Courier New;">cp courier-imap.sysvinit /etc/rc.d/init.d/courier-imapchmod 744 /etc/rc.d/init.d/courier-imap</span>
1 chkconfig --add courier-imapThen I like to use the ntsysv program to double-check that courier-imap is set to launch at boot time
If you aren’t ready to reboot the server now, you can fire up Courier-IMAP in the mean time with this command :
1 /etc/rc.d/init.d/courier-imap start
At this point the Courier-IMAP software should be running. A good way to verify this is to use this command :
1 ps axf
And if all is well, you should be able to see something like this :
12345678 1030 ? S 0:02 /usr/local/courier-imap/libexec/authlib/authdaemond.plain start1031 ? S 1:00 \_ /usr/local/courier-imap/libexec/authlib/authdaemond.plain start1032 ? S 0:59 \_ /usr/local/courier-imap/libexec/authlib/authdaemond.plain start1033 ? S 1:01 \_ /usr/local/courier-imap/libexec/authlib/authdaemond.plain start1035 ? S 1:02 \_ /usr/local/courier-imap/libexec/authlib/authdaemond.plain start1036 ? S 1:02 \_ /usr/local/courier-imap/libexec/authlib/authdaemond.plain start17566 ? S 0:00 /usr/local/courier-imap/libexec/couriertcpd -address=0 -stderrlogger=/usr/local/courier-17569 ? S 0:00 /usr/local/courier-authlib/sbin/courierlogger imapd
SQUIRRELMAIL
the text with yellow background is specific to using MySQL backend. if you don’t want to use MySQL backend, then just skip over these sections….
Go to the SquirrelMail download page, and save the latest source to /usr/local/src. In this example I have used :
1 squirrelmail-1.4.4.tar.gz
Download and unpack all the sources
12345 cd /usr/local/apache/htdocstar xzf /usr/local/src/squirrelmail-1.4.4.tar.gzchown -R root.www squirrelmail-1.4.4chmod -R 750 squirrelmail-1.4.4ln -s squirrelmail-1.4.4 squirrelmail
Create the required directory structure
12345 mkdir /var/squirrelmail# create the data dir. This is where users personal preferences are stored if not using MySQL backendmkdir /var/squirrelmail/data# create the attach dir. This is where temp files for emails in progress are storemkdir /var/squirrelmail/attach
12345 cd squirrelmailcp data/default_pref /var/squirrelmail/datachown -R root.www /var/squirrelmailchmod -R 0770 /var/squirrelmail/datachmod -R 0730 /var/squirrelmail/attach
SquirrelMail allows you to add your company logo to the login page. So whack a copy of your logo into the Apache images directory so it is available for SquirrelMail to use
1 cp /usr/local/src/yourcompanylogo-100.gif /usr/local/apache/htdocs/images
Configure SquirrelMail
12 cd configperl conf.pl
12 D. SET PRE-DEFINED SETTINGS FOR SPECIFIC IMAP SERVERSChoose Courier
1234567 1. ORGANIZATION PREFERENCES1. Organization name : YourCompany WebMail2. Organization Logo : /images/yourcompanylogo-100.gif3. Org. Logo Height/Width : 100/1004. Organization title : YourCompany WebMail (v$version)7. Provider link : http://www.<span style="color: #ff0066;">yourdomain</span>.com8. Provider name : YourCompany
12 2. SERVER SETTINGS1. Domain : <span style="color: #ff0066;">yourdomain.com</span>
12 3. FOLDER DEFAULTS15. Default Unseen Type : 2
123456789101112 4. GENERAL OPTIONS1. Data directory : /var/squirrelmail/data2. Attachment directory : /var/squirrelmail/attach5. Usernames in lower case : true7. Hide SM attributions : true11. Allow server-side sorting : false( Note, server-sorting is faster, but I personally find the sort results to be not as "intuitive"compared with when you let SquirrelMail do the sorting. If you toggle this option on/off and comparethe resultant displays in SquirrelMail you will see what I mean. For example if you server-sort theFROM column then the sort will be done senders email address, whereas if you let SquirrelMail do thesort then column will be sorted on senders name. I would suggest you try toggling thisoption on and off to make your own decision on which sorting method provides the better results.)
12 6. ADDRESS BOOKS2. Use Javascript Address Book Search : True
123 9. DATABASE1. DSN for address book : mysql://<em>squirreluser</em>:<em>squirrelpassword</em>@localhost/squirrelmail3. DSN for preferences : mysql://<em>squirreluser</em>:<em>squirrelpassword</em>@localhost/squirrelmail
1 Now Save and quit the config program
Create the necessary database and tables in MySQL, so that SquirrelMail can store the address books and user preferences there :
1 cd /usr/local/mysql/bin
1 ./mysql --password="<em>mysql-root-</em><em>pwd</em>"
1 CREATE DATABASE squirrelmail;
12 GRANT select,insert,update,delete ON squirrelmail.*TO <em>squirreluser</em>@localhost IDENTIFIED BY '<em>squirrelpassword</em>';
1 USE squirrelmail;
12345678910 CREATE TABLE address (owner varchar(128) DEFAULT '' NOT NULL,nickname varchar(16) DEFAULT '' NOT NULL,firstname varchar(128) DEFAULT '' NOT NULL,lastname varchar(128) DEFAULT '' NOT NULL,email varchar(128) DEFAULT '' NOT NULL,label varchar(255),PRIMARY KEY (owner,nickname),KEY firstname (firstname,lastname));
123456 CREATE TABLE userprefs (user varchar(128) DEFAULT '' NOT NULL,prefkey varchar(64) DEFAULT '' NOT NULL,prefval blob DEFAULT '' NOT NULL,PRIMARY KEY (user,prefkey));
1 quit
You can define what default SquirrelMail settings that users will receive when they log in.
For MySQL backend
123456 cd /usr/local/apache/htdocs/squirrelmail# replace the default preferences definition in the db_prefs file# with our own customised defaults.# Open the file, scroll down and replace the existing "var $default"# entry (on line 102) with our customised version shown belowvi functions/db_prefs.php
1234567891011121314 var $default = Array('chosen_theme' => '../themes/default_theme.php','show_html_default' => '1','language' => 'en_US','use_javascript_addr_book' => '1','left_size' => '140','left_refresh' => '3600','show_username' => '1','show_username_pos' => 'top','order1' => '1','order2' => '2','order3' => '3','order4' => '5','order5' => '4','order6' => '6');
Or, if you aren’t running MySQL backend for SquirrelMail, you can adjust the default preferences like this :
1 vi /var/squirrelmail/data/default_pref :show_html_default=1
language=en_US
use_javascript_addr_book=1
left_size=140
left_refresh=3600
show_username=1
show_username_pos=top
order1=1
order2=2
order3=3
order4=5
order5=4
order6=6
Setup periodic purging of the “attach” directory
When SquirrelMail users are composing a message that has attachment(s), the attachment is temporarily stored in the /var/squirrelmail/attach directory. When the user sends the message, the associated temp files will get deleted.
However sometimes the temp files do not get deleted (eg if the user closes their browser mid-compose?). Since the permissions on this directory are setup (as a security measure) to prevent the webserver from listing the files in this directory, there is no way for Apache/SquirrelMail to do a periodic scan/purge of old files.
So we are going to setup a daily crontab to clean up any attachments that get left hanging around
1 crontab -e
12 # delete any files that are more than 2 days old from the SquirrelMail attachment dir0 0 * * * find /var/squirrelmail/attach/* -atime +2 -exec /bin/rm {} \;
Install the quota_usage plugin so users can see their mailbox quota usage
123 cd /usr/local/srcwget <a href="http://www.squirrelmail.org/plugins/quota_usage-1.2.tar.gz">http://www.squirrelmail.org/plugins/quota_usage-1.2.tar.gz</a>wget <a href="http://www.squirrelmail.org/plugins/compatibility-1.3.tar.gz">http://www.squirrelmail.org/plugins/compatibility-1.3.tar.gz</a>
12345 cd /usr/local/apache/htdocs/squirrelmail/pluginstar xzf /usr/local/src/quota_usage-1.2.tar.gzcp quota_usage/config.php.sample quota_usage/config.phpchown -R root.www quota_usagechmod -R o-rx quota_usage
1234 # qmailadmin and the other tools all classify a 1Mb as 1048576 bytes (1024 * 1024 )# Fix up the quota_plugin so it works with the same units.# Otherwise your quota would show as 20M in qmailadmin, and 21M in SquirrelMail :-/vi quota_usage/functions.php
1 Go to line 43 and change the value 1000000 to 1048576
123 tar xzf /usr/local/src/compatibility-1.3.tar.gzchown -R root.www compatibilitychmod -R o-rx compatibility
12345 cd ../configperl conf.pl8. Pluginschoose quota_usagechoose compatibility
Optionally, Setup SSL mode at login time
12 cd /usr/local/srcwget <a href="http://www.squirrelmail.org/plugins/secure_login-1.0-1.2.8.tar.gz">http://</a><a href="http://www.squirrelmail.org/plugins/secure_login-1.2-1.2.8.tar.gz">www.squirrelmail.org/plugins/secure_login-1.2-1.2.8.tar.gz</a>
12345 cd /usr/local/apache/htdocs/squirrelmail/pluginstar xzf /usr/local/src/secure_login-1.2-1.2.8.tar.gzcp secure_login/config.php.sample secure_login/config.phpchown -R root.www secure_loginchmod -R o-rx secure_login
123 cd ../configperl conf.pl8. Plugins, and choose secure_login
Optionally, modify SquirrelMail so that it will any failed login attempts to the syslog
modify squirrelmail/functions/imap_general.php
search for the line that has “Unknown user or password incorrect”
above this line add :
1 syslog(LOG_MAIL|LOG_NOTICE,"Squirrelmail login failed for Username : $username, Password : $password");
now failed SquirrelMail logins will be logged to /var/log/maillog 🙂
We also added some code to squirrelmail/src/login.php to add a notes page to the login screen. We inserted this chunk just before the line that says “do_hook(‘login_bottom’);
12345678910111213141516171819 echo "<BR><CENTER>"."<TABLE BORDER=1 WIDTH=75%><TR><TD ALIGN=CENTER><FONT FACE=Arial SIZE=2>"."<P><B><FONT SIZE=3>IMPORTANT NOTES REGARDING THE WEBMAIL SYSTEM</FONT></B></P>"."<P><B>AUTOMATIC MAIL DELETION</B></P>"."<P>The mail server will automatically delete mail from the<BR> "."following folders after the specified number of days :<br>"."Trash Folder - 7 days, Sent Folder - 30 days"."<P><B>POP3 MAIL CLIENTS</B></P>"."<P>If you check your mail using a POP3 mail client (such as Outlook Express),<BR> "."it will download and delete the mail from your WebMail inbox.</P>"."<P>If you want to be able to download the mail using POP3 and also<BR> "."leave it on the server so you can see it with WebMail, you will need<BR> "."to adjust the settings in your POP3 client to tell it not to delete<BR> "."mail after downloading.</P>"."<P>For example, to configure this in Outlook Express you would go to<br> "."<i>Tools -> Accounts -> Mail -> Properties -> Advanced</i><BR> "."and then tick the box<BR><i>'Leave a copy of message on server'</i><P>"."</FONT>"."</TD><TR></TABLE></CENTER>";
Now, another cosmetic change… : modify the squirrelmail/src/login.php and change the wording of “Name:” to “Email address:”.
Next, we setup a default document in the web servers root, to redirect our customers through to the SquirrelMail login page. That way when people want to access the WebMail tool they can point their browser to “http://webmail.yourdomain.com” and they will get automatically redirected through to the SquirrelMail directory
1 vi /usr/local/apache/htdocs/index.html
12345678910 <HTML><HEAD><TITLE>Redirect to WebMail login screen...</TITLE><META HTTP-EQUIV="refresh" CONTENT="1; url=http://webmail.<span style="color: #ff0066;">yourdomain.com</span>/squirrelmail/"></HEAD><BODY>Redirecting to the WebMail login screen...<br><a href=squirrelmail/>Click here if you are not automatically redirected</a></BODY></HTML>
SPAM AND VIRUS CHECKING
OK, now you have a working mail server.. You have loaded all your users and they are giving the new system a good workout. Everything is running nice and smoothly. You sit back and think “my job is done!”
Until… users starting coming to you and saying… “Hey, this new mail server is really good… But how do I block out all these viruses and spam?”… Uh oh…!
Well, luckily the answer is relatively easy….. The qmail-scanner program lets us easily implement anti-spam and anti-virus. Installation instructions follow :
OPTIONAL : RAZOR V2
If Razor is installed, SpamAssassin will automatically include it in the list of tests run. We found that Razor is quite accurate in identifying spam, and it only added small amount of extra CPU load on the server, so it is definitely worth installing. Note though, that I believe the licensing of Razor states that it isn’t free for commercial use – so you should probably check the docs before deciding whether you wish to enable this function or not
Compile and install :
12 # install the pre-requisite modules for razorperl -MCPAN -e shell
1 #(enter your way through all the questions. The only one you will likely have to answer is regarding your Continent/Country)
12 # tell the cpan shell to follow the dependency tree and automatically grab any required moduleso conf prerequisites_policy follow
12 # make sure you have some of the basic tools needed to get the CPAN downloads working smoothlyinstall LWP MD5
12 # install the razor pre-requisites nowinstall Net::Ping Net::DNS Time::HiRes Digest::SHA1 Getopt::Long File::Copy Digest::Nilsimsa URI::Escape
1 quit
12 # now install the actual razor softwarewget <a href="http://optusnet.dl.sourceforge.net/sourceforge/razor/razor-agents-2.77.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/razor/razor-agents-2.77.tar.bz2</a>
1234 bunzip2 razor-agents-2.77.tar.bz2tar xf razor-agents-2.77.tarchown -R root.root razor-agents-2.77cd razor-agents-2.77
12345 perl Makefile.PLmakemake testmake installcd ..
The Razor programs will now be installed in /usr/bin. In particular, SpamAssassin makes use of the program called : “razor-check”
Last job is to create the Razor configuration files (they get put into /etc/razor/) by using these commands :
1 razor-admin -d -create -home=/etc/razor
If your server is going to be busy, then I would recommend you edit the razor config file and turn down the debugging level a bit :
1 vi /etc/razor/razor-agent.conf
1 debuglevel=1
SPAMASSASSIN
Description :
SpamAssassin is program that scans email messages using a set of rules, and then assigns a score. If the score is higher than your nominated limit, then the message will be tagged as spam.
1 2 |
# install the pre-requisite modules for spamassassin perl -MCPAN -e shell |
12 # tell the cpan shell to follow the dependency tree and automatically grab any required moduleso conf prerequisites_policy follow
12 # make sure we have all the SpamAssassin prerequisites installedinstall Digest::SHA1 HTML::Parser Storable MIME::Base64 DB_File Net::DNS Net::SMTP Mail::SPF::Query IP::Country::Fast BerkeleyDB
1 exit
Download and compile
1 wget <a href="http://apache.mirror.pacific.net.au/spamassassin/source/Mail-SpamAssassin-3.1.2.tar.gz">http://apache.mirror.pacific.net.au/spamassassin/source/Mail-SpamAssassin-3.1.2.tar.gz</a>
123 tar xzf Mail-SpamAssassin-3.1.2.tar.gzchown -R root.root Mail-SpamAssassin-3.1.2cd Mail-SpamAssassin-3.1.2
1234 perl Makefile.PLmakemake installcd ..
“make install” creates the following main files :
1 /usr/bin/spamassassin <- This is the command-line version of the SpamAssassin program
12 /usr/bin/spamc <- Daemonised SpamAssassin client/usr/bin/spamd <- Daemonised SpamAssassin server
12 /usr/share/spamassassin/ <- The SpamAssassin logic/filter files live here/etc/mail/spamassassin/local.cf <- sitewide configuration settings
Test to see if the installation was successful. (Watch the output from the script. SpamAssassin will add headers to the message. In particular look for the “X-Spam-Status: ” and see if it correctly tags the message with a Yes or No)
12 spamassassin -t < sample-nonspam.txtspamassassin -t < sample-spam.txt
To improve security, modify the configuration of the spamd daemon so it runs under its own uid
Create a spamd user for the spamd process to run as
12 groupadd spamduseradd -g spamd spamd
Modify / create the spamd configuration file
1 vi /etc/sysconfig/spamassassin
123456789101112 # Hint : if you want to enable SpamAssassin debugging# (the debug output goes to /var/log/maillog) then use :# SPAMDOPTIONS="-x -u spamd -H /home/spamd -d -D"# Don't leave debugging turned on unnecessarily though,# because it will slow down a busy server.## Otherwise, for normal operation (debugging disabled) use following combo :# -x means not to look for any per-user preferences ( since all our users are virtual)# -u means to run as userid spamd# -H tells the addon apps like .razor to store all their files into eg /home/spamd/.razor# -d tells spamd to run as a daemonSPAMDOPTIONS="-x -u spamd -H /home/spamd -d"
Configure the spamd daemon so it is running all the time from bootup onwards
123 cp spamd/redhat-rc-script.sh /etc/rc.d/init.d/spamdchmod 700 /etc/rc.d/init.d/spamdcd ..
1 chkconfig --add spamdThen I like to use the ntsysv program to double-check that spamd is set to launch at boot time
Setup the SpamAssassin configuration
1 vi /etc/mail/spamassassin/local.cf
12 # Define the sensitivity level.required_score 5
123 # Allow SpamAssassin to rewrite the subject line of any messages it classifies as spam# This is the value that will prepended to the subject line of messages classified as spamrewrite_header Subject [SPAM]
12 # Put spam analysis reports into to the headers of the message (rather than the body)report_safe 0
12345678 # Enable SpamAssassin's RBL checking features :# Although we have already done some RBL filtering earier in qmail's rblsmtpd program,# it is still recommended to turn on RBL checking in SpamAssassin, as it will run# checks against a variety of different RBL sources, and the results will help# tag spam more accuratelyskip_rbl_checks 0# If we haven't received a response from the RBL server in X seconds, then skip that testrbl_timeout 3
1234567 # You can nominate any netblocks that you control, and contain mailservers that# you trust. IE you control the mailservers in these netblocks so there is no# need to be running RBL checks against these particular servers.# You should include all the netblocks used by email clients on your local lan.# Also make sure you include any netblocks that host your mail servers.trusted_networks 127.0.0.1trusted_networks 123.123.123.0/24
12345 # Enable auto-learninguse_bayes 1bayes_auto_learn 1# we are going to run a single global bayes db for all users ( rather than a db per user)bayes_path /home/spamd/.spamassassin/bayes
12 # Enable auto-whitelistinguse_auto_whitelist 1
Just to make sure the bayes database directory will be setup correctly :
12 mkdir /home/spamd/.spamassassinchown -R spamd.spamd /home/spamd/.spamassassin
If you wish to view all the possible configuration options, use this command :
1 perldoc Mail::SpamAssassin::Conf
Enable the razor functions
1 vi /etc/mail/spamassassin/v310.pre
1 #uncomment the following line :
1 loadplugin Mail::SpamAssassin::Plugin::Razor2
OK, the SpamAssassin software is now fully installed!
Any mail that SpamAssassin classifies as spam will have [SPAM] added to the subject line. You should now probably setup some docs for your users showing them how they can use message filtering rules in their email client. You can see our message filtering guides here
If you aren’t ready to reboot the server now, you can fire up spamd in the mean time with this command :
1 /etc/rc.d/init.d/spamd start
If all goes well you will see some output like this :
1 9721 ? S 0:01 /usr/bin/spamd -x -u spamd -H /home/spamd -d
(Note that spam filtering isn’t actually operational on your server yet, you need to use the qmail-scanner program to feed mail through the SpamAssassin scripts)
CLAM ANTI-VIRUS
Clam antivirus can run in two different modes. Either as a normal command line scanner, or as a client/daemon pair.
When working as a command line scanner, you perform your scanning using the program “clamscan”. If a complex program like a virus scanner is run repetitively (ie being launched for every email that passes through your system), it chews up a lot of CPU/disk resources. To get around this issue you can launch Clam as a daemon (clamd). This is where a copy of Clam is launched and stays active in the background. You then do your scanning using the clamdscan client, which is only small, thus making it fast to launch/run. The client sends commands to the daemon, and the daemon will take care of scanning the message and returning the results to the client. (The same technique is used by SpamAssassin where you can use the full spamassassin command line version, or the spamc/spamd client/daemon pair).
In a busy environment, there is no doubt that the client/daemon method is the best way to go
12 groupadd clamavuseradd -g clamav -s /bin/false -c "Clam AntiVirus" clamav
12345678 cd /usr/local/srcwget <a href="http://optusnet.dl.sourceforge.net/sourceforge/clamav/clamav-0.88.tar.gz">http://optusnet.dl.sourceforge.net/sourceforge/clamav/clamav-0.88.tar.gz</a>tar xzf clamav-0.88.tar.gzchown -R root.root clamav-0.88cd clamav-0.88./configuremakemake install
Customise the clamd configuration file
1 vi /usr/local/etc/clamd.conf
1 # make sure you comment out the "example" line
123 LogSyslogFixStaleSocketUser clamav
Configure clamd so it is running all the time from bootup onwards
12 cp contrib/init/RedHat/clamd /etc/rc.d/init.d/chmod 744 /etc/rc.d/init.d/clamd
1 chkconfig --add clamd
Then I like to use the ntsysv program to double-check that clamd is set to launch at boot time
If you aren’t ready to reboot the server now, you can fire up clamd in the mean time with this command :
1 /etc/rc.d/init.d/clamd start
At this point the clamd software should be running. A good way to verify this is to use this command :
1 ps axf
And if all is well, you should be able to see something like this :
1 18144 ? S 0:00 /usr/local/sbin/clamd
Setup the freshclam configuration file
1 vi /usr/local/etc/freshclam.conf
12345 # make sure you comment out the "example" lineLogSyslogDatabaseOwner clamavDatabaseMirror db.au.clamav.net (where "au" matches <em>your</em> country code)NotifyClamd
Configure freshclam to start on boot
1 vi /etc/rc.d/rc.local
1 /usr/local/bin/freshclam -d
Launch freshclam now
1 /usr/local/bin/freshclam -d
At this point the freshclam software should be running. A good way to verify this is to use this command :
1 ps axf
And if all is well, you should be able to see something like this :
1 18144 ? S 0:00 /usr/local/sbin/clamd
QMAIL-SCANNER
http://qmail-scanner.sourceforge.net
Description :
Qmail-Scanner is an add-on that enables a qmail server to scan messages for certain characteristics. It is typically used for its anti-virus protection functions, in which case it is used in conjunction with commercial (or open source) virus scanners. It also capable of blocking email that contains specific strings in particular headers, or particular attachment filenames or types (e.g. *.VBS attachments).
Install the required supporting modules for Qmail-Scanner
TNEF unpacker
1 <a href="http://sourceforge.net/projects/tnef/">http://sourceforge.net/projects/tnef/</a>
12 cd /usr/local/srcwget <a href="http://optusnet.dl.sourceforge.net/sourceforge/tnef/tnef-1.3.4.tar.gz">http://optusnet.dl.sourceforge.net/sourceforge/tnef/tnef-1.3.4.tar.gz</a>
1234567 tar xzf tnef-1.3.4.tar.gzchown -R root.root tnef-1.3.4cd tnef-1.3.4./configuremakemake installcd ..
ReformatMIME (from the Maildrop package)
1 <a href="http://sourceforge.net/projects/courier">http://sourceforge.net/projects/courier</a>
12 cd /usr/local/srcwget <a href="http://prdownloads.sourceforge.net/courier/maildrop-2.0.1.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/courier/maildrop-2.0.1.tar.bz2</a>
123456789 bunzip2 maildrop-2.0.1.tar.bz2tar xf maildrop-2.0.1.tarchown -R root.root maildrop-2.0.1.tarcd maildrop-2.0.1./configuremakemake install-stripmake install-mancd ..
A “Qmail-Scanner ST patch” has been released by Salvatore Toribio, which greatly extends the functionality of qmail-scanner. The patch adds extra features to help deal with spam (such as dropping messages that exceed a certain SpamAssassin score). We are going to use this patch, as it makes qmail-scanner much more useful.
1 cd /usr/local/src
1234 # Grab the qmail-scanner sourcewget <a href="http://optusnet.dl.sourceforge.net/sourceforge/qmail-scanner/qmail-scanner-1.25.tgz">http://optusnet.dl.sourceforge.net/sourceforge/qmail-scanner/qmail-scanner-1.25.tgz</a>tar xzf qmail-scanner-1.25.tgzchown -R root.root qmail-scanner-1.25
1234 # Grab and apply the qmail-scanner-st patchwget <a href="http://toribio.apollinare.org/qmail-scanner/download/q-s-1.25st-20050406.patch.gz">http://toribio.apollinare.org/qmail-scanner/download/q-s-1.25st-20050406.patch.gz</a>gunzip q-s-1.25st-20050406.patch.gzpatch -p0 < q-s-1.25st-20050406.patch
1 cd qmail-scanner-1.25
Now at this point, I would recommend you spend some time reading the qmail-scanner documentation. And once you have read that, take a look at the qmail-scanner-st patch doco
Next, create a user and group for the qmailscanner to run under
12 groupadd qscanduseradd -c "Qmail-Scanner Account" -g qscand -s /bin/false qscand
For qmailscanner to work correctly with clamav, you need to adjust clamav to run under the qscand username
1 vi /usr/local/etc/clamd.conf
12 # look for the line that says "User clamav" and replace withUser qscand
1 /etc/rc.d/init.d/clamd restart
Configure Qmail-Scanner :
123456789101112131415161718 # Here are the settings we used at our site for configuring Qmail-Scanner :## configure Qmail-Scanner to work in the following manner :# - notify a nominated admin each time a virus is detected# (in this case it will be virusadmin@<span style="color: #ff0066;">yourdomain.com</span>)# - use the client/server version of Clam AV for anti-virus scanning.# - enable support for spamc/spamd in "verbose" mode.# Qmail-Scanner can run spamd in "fast" mode or "verbose" mode.# You can read more about this at the <a href="http://qmail-scanner.sourceforge.net/FAQ.php">Qmail-Scanner FAQ page</a>.# I would recommend that you use verbose mode as this allows you to get access to# the full reporting/tagging features that SpamAssassin can provide. It costs you# a fraction more CPU power, but provides a much greater range of features.# - Use a medium level of sensitivity when blocking mail due to broken MIME formatting## THE COMMANDS HIGHLIGHTED IN BLUE BELOW ARE FROM THE QMAIL-SCANNER-ST PATCH# - sa-delete sets the point that spam mail is autodeleted.# <em>sa-delete</em> is a relative value to the SpamAssassin <em>required_hits</em>.# so in our case, the spam will be deleted at a score of 10
1234567891011 ./configure \--admin virusadmin \--domain <span style="color: #ff0066;">yourdomain.com</span> \--admin-fromname "<span style="color: #ff0066;">yourdomain.com</span> Postmaster" \--local-domains "<span style="color: #ff0066;">yourdomain.com</span>" \--scanners clamdscan,verbose_spamassassin \--fix-mime 1 \--debug no \--sa-delete 5 \--sa-reject yes \--install
Note : If the install fails with an error like this :
1 <span style="font-family: Courier New; font-size: x-small;">Redhat hosts need to have perl-suidperl installed to get setuid support</span>Then you will need to do something like this (this example for Redhat 7.3) :
123 cd /usr/local/srcwget <a href="http://redhat.pacific.net.au/redhat/redhat-7.3-en/os/i386/RedHat/RPMS/perl-suidperl-5.6.1-34.99.6.i386.rpm">http://redhat.pacific.net.au/redhat/redhat-7.3-en/os/i386/RedHat/RPMS/perl-suidperl-5.6.1-34.99.6.i386.rpm</a>rpm -ivh perl-suidperl-5.6.1-34.99.6.i386.rpm
Edit the perscanner file which is used to block mail that contains particular strings. perlscanner is a tool that is included with qmail-scanner, and it is executed after all the other anti-virus scanners have run (eg clamscan). This system provides a good failsafe in case some new virus comes along that the virus-scanner cant detect yet. perlscanner is perfect for blocking those virus-prone attachments that have no legitimate purpose in email.
1 vi /var/spool/qscan/quarantine-events.txtUncomment the following lines :
1234567 .lnk SIZE=-1 LNK files not allowed per Company security policy.wsh SIZE=-1 WSH files not allowed per Company security policy.vbs SIZE=-1 VBS files not allowed per Company security policy.scr SIZE=-1 SCR files not allowed per Company security policy.hta SIZE=-1 HTA files not allowed per Company security policy.pif SIZE=-1 PIF files not allowed per Company security policy.cpl SIZE=-1 CPL files not allowed per Company security policy
12 # rebuild the perlscanner databasesetuidgid qmaild /var/qmail/bin/qmail-scanner-queue.pl -g
Any SMTP sessions that are dropped (due to network outages/etc) may lead to files lying around in /var/spool/qmailscan . Running /var/qmail/bin/qmail-scanner-queue.pl -z at least once daily will ensure such files are deleted when they’re over 30 hours old. We will make a cronjob to do that :
1 crontab -e
1 0 0 * * * /var/qmail/bin/qmail-scanner-queue.pl -z
Now define what mail is to be sent through the Qmail-Scanner, also make sure that your qmail-smtpd script allocates sufficient resources to support the needs of Qmail-Scanner + Antivirus + SpamAssassin. At our site, we have configured Qmail-Scanner to virusscan all messages (ie inbound and outbound mail). We did this by setting up our our /var/qmail/supervise/qmail-smtpd/run file like this :
1 vi /var/qmail/supervise/qmail-smtpd/run
1234567891011121314 #!/bin/sh<strong># when QMAILQUEUE is set, all mail will be sent to the nominated scriptQMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl" export QMAILQUEUE</strong>QMAILDUID=`id -u qmaild`NOFILESGID=`id -g qmaild`<strong># softlimit needs to be set at something large such as 15000000# to allow virusscanning software to run successfully</strong>exec /usr/local/bin/softlimit -m <strong>15000000</strong> \/usr/local/bin/tcpserver \-v -x /etc/tcp.smtp.cdb \-c 20 -R -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \... and the rest of the file snipped ...
Restart the qmail-smtpd service :
12 svc -d /service/qmail-smtpdsvc -u /service/qmail-smtpd
However, if you don’t want to virusscan all mail, you can selectively nominate which IP ranges should or shouldn’t be checked by setting the QMAILQUEUE variable via your /etc/tcp.smtp file rather than inside the supervise/qmail-smtpd/run file. Refer to the Qmail-Scanner home page for setup examples.
QMAIL-SCANNER / SPAMASSASSIN NOTES :
How can I tell if SpamAssassin is working?
Each time SpamAssassin processes a message, it will log some information to /var/log/maillog (score, message size, time taken to process)
Not all mail gets passed through SpamAssassin
We have configured our supervise/qmail-smtpd/run script so that it runs Qmail-Scanner for every mail message. This means all incoming and outgoing mail will get virus-checked. However this doesn’t necessarily mean that every message passing through Qmail-Scanner will also get sent through SpamAssassin.
Qmail-Scanner has been coded so that messages are only passed onto SpamAssassin if the RELAYCLIENT variable from tcp.smtp is not set. The idea behind this to reduce load on the system by not running SpamAssassin on mail originated by your users.
It is possible to force SpamAssassin checking for local users if you choose by setting QS_SPAMASSASSIN=”on” for the appropriate entries in your tcp.smtp file
You can read more about this subject at the Qmail-Scanner FAQ page
Is it possible to configure per-user settings for SpamAssassin?
It depends on your configuration. We believe it will be possible to implement an interface so that vpopmail users can turn SpamAssassin checking on/off, and also set their own custom required_hits. We are hoping to store these settings as additional columns in the vpopmail MySQL database… Stay tuned and we will post more info as it comes to hand
Can I make it so that all the spam get sent to my a SPAM or TRASH folder?
Yes, have a look at this example, or take a look at the $smaildir option in the qmail-scanner-st patch
Qmail-scanner’s quarantine directory
Each virus infect mail message gets quarantines into the following directory :
1 /var/spool/qmailscan/quarantine/new
So you will need to periodically purge the files from that dir, or else your hard disk will eventually fill up!
eg setup a crontab entry like this :
1 0 * * * * find /var/spool/qmailscan/quarantine/new -type f -mtime +30 -exec rm '{}' \;