BILL’S QMAIL
 
经过苦苦两个月……qmail终于配置完成,兴奋无比,感谢bill ,一路走来,将日志发布出来与大家共享!
Getting Started
  • DNS
Before we begin, make sure DNS (mx record) is properly setup. If you were using "merchbox.com" as your virtual domain, here's how your host lookups would look after setting up dns:
[shupp@ns1 toaster]$ host -t mx merchbox.com
merchbox.com. mail is handled by 0 mail.merchbox.com.
[shupp@ns1 toaster]$ host -t a mail.merchbox.com
mail.merchbox.com. has address 216.234.249.114
主机名也应正确:
/etc/sysconfig/network
Like this HOSTNAME= qmail.abc.com
/etc/hosts
Like this 192.168.1.1 qmail.abc.com qmail
  • Remove existing smtp/pop/imap servers
Now we must remove any existing installations of sendmail/postfix and disable pop/imap servers. To remove sendmail and postfix from an rpm based distribution, try this:
rpm -e --nodeps sendmail postfix
Unless you have other services that absolutely have to run on this machine, I recommend shutting down inetd or xinetd altogether and removing it from your startup scripts. The only thing you'll need (outside of what we're about to isntall) is ssh, which is probably installed already. This will likely shut off any pop3 or imap servers, as well as other unneccessary ports. Otherwise, disable them manually.
To be sure that these services are disabled, try telnetting to ports 25, 110, and 143 and make sure your connections are refused.
  • Download Packages
I keep my software source in /var/src. If you want to put it in another location, set the location below, and all paths will be updated.
umask 0022
mkdir -p /var/src/tar
cd /var/src/tar
wget [url]http://cr.yp.to/daemontools/daemontools-0.76.tar.gz[/url]
wget [url]http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz[/url]
wget [url]http://shupp.org/software/netqmail-1.05.tar.gz[/url]
wget [url]http://shupp.org/software/libdomainkeys-0.68.tar.gz[/url]
wget [url]http://shupp.org/patches/libdomainkeys.diff[/url]
wget [url]http://shupp.org/patches/qmail-toaster-0.9.1.patch.bz2[/url]
wget [url]http://shupp.org/patches/doublebounce-trim.patch[/url]
wget [url]http://shupp.org/software/vpopmail-5.4.18.tar.gz[/url]
wget [url]http://shupp.org/patches/vpopmail-5.4.18-cumulative.patch[/url]
wget [url]http://shupp.org/software/autorespond-2.0.4.tar.gz[/url]
wget [url]http://shupp.org/patches/autorespond-2.0.4-2.0.5.patch[/url]
wget [url]http://shupp.org/software/qmailadmin-1.2.11.tar.gz[/url]
wget [url]http://shupp.org/software/qmailadmin-help-1.0.8.tar.gz[/url]
wget [url]http://cr.yp.to/software/ezmlm-0.53.tar.gz[/url]
wget [url]http://shupp.org/software/ezmlm-idx-0.443.tar.gz[/url]
wget [url]http://shupp.org/software/courier-imap-4.1.2.tar.bz2[/url]
wget [url]http://shupp.org/software/courier-authlib-0.59.1.tar.bz2[/url]
wget [url]http://shupp.org/patches/vpopmail_courier_cram-1.diff[/url]
wget [url]http://shupp.org/software/squirrelmail-1.4.9a.tar.bz2[/url]
wget [url]http://shupp.org/software/quota_usage-1.3.1-1.2.7.tar.gz[/url]
wget [url]http://shupp.org/software/toaster-scripts-0.9.0.tar.gz[/url]
cd ../
tar -xzf tar/netqmail-1.05.tar.gz
cd netqmail-1.05
./collate.sh
正常情况应该出来7项
Install Software
Now that you have downloaded all the software packages to /var/src, please go through each of these installation steps as the appear, and in this order, unless you really know what you're doing. (Because if you did, you wouldn't be reading this, right?)
The below steps assume that your "rc" directories are in /etc/ and your "init.d" path is "/etc/init.d" . If yours are different, please substitue paths accordingly.
  • daemontools
daemontools is a collection of tools for managing UNIX services. It will monitor qmail-send, and qmail-smtpd, and qmail-pop3d services.
Install:
mkdir -p /package
chmod 1755 /package
cd /package
tar -xpzf /var/src/tar/daemontools-0.76.tar.gz
cd admin/daemontools-0.76
patch -p1 < /var/src/netqmail-1.05/other-patches/daemontools-0.76.errno.patch
package/install
# add the "clear" service
cd ../
mkdir clear
touch clear/down
cat > clear/run <&lt;EOF
#!/bin/sh
yes '' | head -4000 | tr '\n' .
# When you want to clear the service errors, just run this:
# svc -o /service/clear
EOF
chmod +x clear/run
chmod a-w clear/down
ln -s /package/admin/clear /service/clear
To verify that daemontools is running, make sure that `ps ax` reports '/bin/sh /command/svscanboot' and 'svscan /service' as running.
Install Software
  • ucspi-tcp
ucspi-tcp contains tcpserver and tcpclient, command line tools for building client-server applications.
Install:
cd /var/src
tar -xzf tar/ucspi-tcp-0.88.tar.gz
cd ucspi-tcp-0.88
patch -p1 &lt; /var/src/netqmail-1.05/other-patches/ucspi-tcp-0.88.errno.patch
# NOTE: If you are on the x86_64 platform, you need to remove the "-02" argument to gcc in conf-cc. See
this for details
make
make setup check
  • qmail
qmail is allegedly the second most popular MTA in use, known for speed and security.
The patch you will apply later is a composite of these existing patches:
    • smtp auth (cram-md5)
    • starttls support
    • support oversize dns packets (not necessary if you use dnscache)
    • qregex (regular expression matching in badmailfrom and badmailto)
    • reread concurrency via HUP
    • big concurrency (set the spawn limit above 255)
    • maildir++ patch
    • qmail-queue (to allow for virus scanners, part of netqmail)
    • chkuser (check for local users, envelope syntax) with user extensions enabled (for TMDA)
    • spam throttle
    • spf
    • surbl support in qmail-smtpd
    • domainkeys support
Install:
mkdir /var/qmail
groupadd nofiles
useradd -g nofiles -d /var/qmail/alias alias
useradd -g nofiles -d /var/qmail qmaild
useradd -g nofiles -d /var/qmail qmaill
useradd -g nofiles -d /var/qmail qmailp
groupadd qmail
useradd -g qmail -d /var/qmail qmailq
useradd -g qmail -d /var/qmail qmailr
useradd -g qmail -d /var/qmail qmails
cd /var/src
tar -xzf tar/toaster-scripts-0.9.0.tar.gz
cd netqmail-1.05/netqmail-1.05
# NOTE: RedHat/Fedora users may need to link certain include files for the TLS patch.
# Issue the command below only if make fails:
ln -s /usr/kerberos/include/com_err.h /usr/kerberos/include/krb5.h \
/usr/kerberos/include/profile.h /usr/include/
# as well as remove the sendmail link if it still exists:
rm /usr/sbin/sendmail
make
make setup check
# NOTE: qmail will be patched AFTER vpopmail is installed
# turn on SPF checking
echo 3 > /var/qmail/control/spfbehavior
# Setup the primary administrator's email address.
# This address will receive mail for root, postmaster, and mailer-daemon.
# Replace "[email]admin@example.com[/email]" with your email address
(cd ~alias; echo "[email]admin@example.com[/email]" &gt; .qmail-postmaster ;\
echo "[email]admin@example.com[/email]" &gt; .qmail-mailer-daemon ;\
echo "[email]admin@example.com[/email]" &gt; .qmail-root )
chmod 644 ~alias/.qmail*
cd /var/src/netqmail-1.05/netqmail-1.05
./config-fast `hostname --long`
(此处用自己的域名代替hostname --long)
Configure:
add qmail man pages to MANPATH Edit /etc/man.config
o Add "MANPATH /var/qmail/man"
o NOTE: Debian users should set MANDATORY_MANPATH rather than MANPATH
cd /var/src
cp toaster-scripts-0.9.0/rc /var/qmail/rc
chmod 755 /var/qmail/rc
mkdir /var/log/qmail
echo ./Maildir/ &gt;/var/qmail/control/defaultdelivery
cp toaster-scripts-0.9.0/qmailctl /var/qmail/bin/
chmod 755 /var/qmail/bin/qmailctl
ln -s /var/qmail/bin/qmailctl /usr/bin
ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
# Now create the supervise directories/scripts for the qmail services:
mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
mkdir -p /var/qmail/supervise/qmail-pop3d/log
mkdir -p /var/qmail/supervise/qmail-pop3ds/log
cp /var/src/toaster-scripts-0.9.0/send.run /var/qmail/supervise/qmail-send/run
cp /var/src/toaster-scripts-0.9.0/send.log.run /var/qmail/supervise/qmail-send/log/run
cp /var/src/toaster-scripts-0.9.0/smtpd.run /var/qmail/supervise/qmail-smtpd/run
cp /var/src/toaster-scripts-0.9.0/smtpd.log.run /var/qmail/supervise/qmail-smtpd/log/run
cp /var/src/toaster-scripts-0.9.0/pop3d.run /var/qmail/supervise/qmail-pop3d/run
cp /var/src/toaster-scripts-0.9.0/pop3d.log.run /var/qmail/supervise/qmail-pop3d/log/run
# NOTE: If you are using stunnel version 4, you should use pop3ds.run.v4
# instead of pop3ds.run below.
# Type "stunnel -V" (v. 3) or "stunnel -version" (v. 4) to see what version is installed.
# You will also need to copy over stunnel.conf like so:
#
# cp /var/src/toaster-scripts-0.9.0/stunnel.conf /var/qmail/supervise/qmail-pop3ds/
cp /var/src/toaster-scripts-0.9.0/pop3ds.run /var/qmail/supervise/qmail-pop3ds/run
cp /var/src/toaster-scripts-0.9.0/pop3ds.log.run /var/qmail/supervise/qmail-pop3ds/log/run
echo 20 &gt; /var/qmail/control/concurrencyincoming
chmod 644 /var/qmail/control/concurrencyincoming
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
chmod 755 /var/qmail/supervise/qmail-pop3ds/run
chmod 755 /var/qmail/supervise/qmail-pop3ds/log/run
mkdir -p /var/log/qmail/smtpd
mkdir -p /var/log/qmail/pop3d
mkdir -p /var/log/qmail/pop3ds
chown -R qmaill /var/log/qmail
# allow daemontools to start qmail
ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /service
# verify that it's running with qmailctl
sleep 5
qmailctl stat
Now let's compile libdomainkeys, we'll need that later:
cd /var/src
tar -xzf tar/libdomainkeys-0.68.tar.gz
cd libdomainkeys-0.68
patch -p0 < ../tar/libdomainkeys.diff
make
Install Software
  • Vpopmail
Vpopmail is a virtual domain package add-on for qmail. It can handle multiple domains on a single IP address, and none of the user accounts are /etc/passwd or "system" accounts.
Install:
groupadd -g 89 vchkpw
useradd -u 89 -g vchkpw vpopmail
cd /var/src
tar -xzf tar/vpopmail-5.4.18.tar.gz
cd vpopmail-5.4.18
patch -p0 &lt; ../tar/vpopmail-5.4.18-cumulative.patch
# NOTE: If you are on the x86_64 platform, you need to set the CFLAGS compiler environment by prefacing the next command with "CFLAGS=-fPIC" , like so: "CFLAGS=-fPIC ./configure ..."
./configure --enable-logging=v
make
make install-strip
# NOTE: If you are on the x86_64 platform, you need to edit cdb/compile to add the -fPIC argument to cc. It should look something like this: 'exec gcc -fPIC -02 -c ${1+"$@"}' After editing compile, do "make && make install-strip" again. see this post for more details
echo '127.:allow,RELAYCLIENT=""' > ~vpopmail/etc/tcp.smtp
(cd ~vpopmail/etc ; tcprules tcp.smtp.cdb tcp.smtp.tmp < tcp.smtp)
# install the vpopmail start script
cp /var/src/toaster-scripts-0.9.0/vpopmailctl /var/qmail/bin/vpopmailctl
chmod 755 /var/qmail/bin/vpopmailctl
ln -s /var/qmail/bin/vpopmailctl /usr/bin
# add qmail toaster patch now that vpopmail is installed
cd /var/src/netqmail-1.05/netqmail-1.05
bunzip2 -c ../../tar/qmail-toaster-0.9.1.patch.bz2 | patch -p0
make clean
make
qmailctl stop
make setup check
# NOTE: the following command needs to be run after any future re-installs of qmail as it will chown this directory back to qmail
chown -R vpopmail:vchkpw /var/qmail/spam
make cert
# enter your company's information
make tmprsadh
# NOTE: This may take a LONG time
# now add the followowing line to your crontab via `crontab -e` to update these temp keys each night
01 01 * * * /var/qmail/bin/update_tmprsadh > /dev/null 2&gt;&1
# start qmail back up
qmailctl start
# allow daemontools to start vpopmail
ln -s /var/qmail/supervise/qmail-pop3d /var/qmail/supervise/qmail-pop3ds /service
# verify that it's running with vpopmailctl
sleep 5
vpopmailctl stat
Install Software
  • Courier-IMAP
Courier-IMAP will supply IMAP/SIMAP access.
NOTE: If you are on a system that does not use GNU make, such as FreeBSD, install GNU make and substitue 'gmake' for 'make' during the install of courier-authlib and courier-imap. Most Linux systems use GNU make.
Install Courier's Auth Library:
cd /var/src
tar -xjf tar/courier-authlib-0.59.1.tar.bz2
cd courier-authlib-0.59.1
patch -p0 < ../tar/vpopmail_courier_cram-1.diff
./configure
# NOTE: RedHat/Fedora users need to add "--with-redhat"
make
make install-strip
make install-configure
cp courier-authlib.sysvinit /etc/init.d/courier-authlib
chmod 755 /etc/init.d/courier-authlib
ln -s ../init.d/courier-authlib /etc/rc0.d/K30courier-authlib
ln -s ../init.d/courier-authlib /etc/rc1.d/K30courier-authlib
ln -s ../init.d/courier-authlib /etc/rc2.d/S80courier-authlib
ln -s ../init.d/courier-authlib /etc/rc3.d/S80courier-authlib
ln -s ../init.d/courier-authlib /etc/rc4.d/S80courier-authlib
ln -s ../init.d/courier-authlib /etc/rc5.d/S80courier-authlib
ln -s ../init.d/courier-authlib /etc/rc6.d/K30courier-authlib
Configure:
Edit /usr/local/etc/authlib/authdaemonrc
o Change authmodulelist= "..." to authmodulelist= "authvchkpw"
o Start Authlib's Authdaemon Server
o /etc/init.d/courier-authlib start
Install Courier-IMAP:
cd /var/src
tar -xjf tar/courier-imap-4.1.2.tar.bz2
cd courier-imap-4.1.2
# build as vpopmail
chown -R vpopmail:vchkpw ../courier-imap-4.1.2
su vpopmail
umask 0022
# configure may take some time...
./configure
# NOTE: RedHat/Fedora users need to add '--with-redhat'
make
exit
make install-strip
make install-configure
cp courier-imap.sysvinit /etc/init.d/courier-imap
chmod 755 /etc/init.d/courier-imap
ln -s ../init.d/courier-imap /etc/rc0.d/K30courier-imap
ln -s ../init.d/courier-imap /etc/rc1.d/K30courier-imap
ln -s ../init.d/courier-imap /etc/rc2.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc3.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc4.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc5.d/S80courier-imap
ln -s ../init.d/courier-imap /etc/rc6.d/K30courier-imap
Configure:
Edit /usr/lib/courier-imap/etc/imapd
o Change 'IMAPDSTART=NO' to 'IMAPDSTART=YES'
o add " AUTH=CRAM-MD5" to IMAP_CAPABILITY to enable secure authentication (CRAM-MD5)
Edit /usr/lib/courier-imap/etc/imapd-ssl
o Change 'IMAPDSSLSTART=NO' to 'IMAPDSSLSTART=YES'
o optional: The first time courier-imap is started, the SSL certificate is first created using 'localhost' as the 'common name'. If you want to change this to match your hostname, you can customize the CN line in /usr/lib/courier-imap/etc/imapd.cnf (and pop3d.cnf of you choose to use courier's pop3d) so that the common name matches your server name BEFORE you start the server for the first time.
Start IMAP server
/etc/init.d/courier-imap start
Install Software
  • SquirrelMail
SquirrelMail is a web based IMAP client
NOTE: This section assumes that your apache ServerRoot is /var/www and that your DocumentRoot is /var/www/html, and also that your web server runs as apache:apache
Install:
cd /var/src
tar -xjf tar/squirrelmail-1.4.9a.tar.bz2
cd squirrelmail-1.4.9a
cd plugins
tar -xzf ../../tar/quota_usage-1.3.1-1.2.7.tar.gz
cp quota_usage/config.php.sample quota_usage/config.php
cd ../
./configure
here you will have to set a few options:
o go to Server Settings (2),goto server (A) Server Software (8) and change the Server Software from "other" to "courier" (a)
o From the main menu, go to General Options (4) and change Data Direcotry (2) to "/var/www/data/" , change "Allow server thread sort" (10) to y, and change "Allow server-side sorting" (11) to y.
o From the main menu, go to Plugins and enable the quota_usage plugin, along with any others you prefer
o Save settings
o quit
# move the data directory into place and change permissions to the user:group that the web server runs as:
mv data /var/www/
chown -R apache:apache /var/www/data
# install squirrelmail
cd ../
mv squirrelmail-1.4.9a /var/www/html/
Install Software
  • autorespond
Autorespond is compatible autoresponder/vacation type tool that works well with vdelivermail and qmailadmin.
Install:
cd /var/src
tar -xzf tar/autorespond-2.0.4.tar.gz
cd autorespond-2.0.4
patch -p1 &lt; ../tar/autorespond-2.0.4-2.0.5.patch
make
make install
Install Software
  • ezmlm-idx
Fast, full featured Mailing List Manager configureable from qmailadmin.
Install:
cd /var/src
tar -xzf tar/ezmlm-0.53.tar.gz
tar -xzf tar/ezmlm-idx-0.443.tar.gz
mv ezmlm-idx-0.443/* ezmlm-0.53/
cd ezmlm-0.53
patch -p0 &lt; idx.patch
make
make setup
Install Software
  • QmailAdmin
QmailAdmin can handle nearly all virtual email administration tasks for you from a web browser, except for adding and removing virtual domains.
Install:
cd /var/src
tar -xzf tar/qmailadmin-1.2.11.tar.gz
cd qmailadmin-1.2.11
./configure --enable-help --enable-htmldir=/var/www/html --enable-cgibindir=/var/www/cgi-bin
make
make install-strip
cd ../
tar -xzf tar/qmailadmin-help-1.0.8.tar.gz
cd qmailadmin-help-1.0.8
mkdir /var/www/html/p_w_picpaths/qmailadmin/help
cp -rp * /var/www/html/p_w_picpaths/qmailadmin/help
Your toaster installation is done! Now we're ready to take it for a test drive.
Test Drive
Here we'll add a virtual domain, 'test.com', and test sending/receiving mail. Substitue 'test.com' for whatever domain you setup DNS for.
# Add the domain to vpopmail
/home/vpopmail/bin/vadddomain test.com [password]
This creates the default "postmaster" account for test.com. You will use this account with qmailadmin. Try adding/removing users with qmailadmin here:
[url]http://mail.test.com/cgi-bin/qmailadmin[/url]
To test out quota usage support, create a user with a 6MB quota like so:
/home/vpopmail/bin/vadduser -q 6MB [email]user@test.com[/email] [password]
# verify the user settings, and create the "maildirsize" file
/home/vpopmail/bin/vuserinfo [email]user@test.com[/email]
Now, to log into SquirrelMail as [email]user@test.com[/email], point your browser here:
[url]http://mail.test.com/squirrelmail-1.4.9a/[/url]
Send yourself a message. If you get it, it's likely you're up and running.
To test your POP server, try telnetting to port 110 and logging in.
# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
+OK &lt;25248.1175148975@localhost>
user [email]user@test.com[/email]
+OK
pass [password]
+OK logged in.
quit
+OK
Connection closed by foreign host.
Test your IMAP server in the same way:
# telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
* OK Courier-IMAP ready. Copyright 1998-2001 Double Precision, Inc. See COPYING for distribution information.
a001 login [email]user@test.com[/email] [password]
a001 OK LOGIN Ok.
a001 logout
* BYE Courier-IMAP server shutting down
a001 OK LOGOUT completed
Connection closed by foreign host.
To test our SSL/TLS connections, all you need to do is duplicate the same tests above, but use openssl's s_client tool to handle encryption.
# for pop:
openssl s_client -connect localhost:995
# for imap:
openssl s_client -connect localhost:993
# for smtp/tls:
openssl s_client -crlf -starttls smtp -connect localhost:25
NOTE: If you get an error like this:
20656:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure:s23_clnt.c:473:
your qmail install might need the cipher lists. Debian does this, I don't know why. The following commands will fix it:
openssl ciphers &gt; /var/qmail/control/tlsclientciphers
openssl ciphers &gt; /var/qmail/control/tlsserverciphers
Options
Here, you can add 4 tools that together will prevent viruses from reaching your system via email, and tag spam for client filtering
  • SpamAssassin
SpamAssassin is the leading open source spam scanner. We'll be installing SpamAssassin via CPAN below.
NOTE: Debian users should have installed the SpamAssassin prerequisites during 'Debian Notes' eariler. RPM distributions may want to use 'yum install spamassassin' instead of CPAN below, so that you get all the dependencies. If the RPM of SpamAssassin is out of date, you could then simply do 'yum uninstall spamassassin', and follow the CPAN installation below, as you'll have the dependencies.
Install:
cd /root
perl -MCPAN -e shell
o conf prerequisites_policy ask
install Mail::SpamAssassin
quit
# run spamd under daemontools
mkdir -p /var/qmail/supervise/spamd/log
mkdir -p /var/log/spamd
chown qmaill /var/log/spamd
cp /var/src/toaster-scripts-0.9.0/spamd.run /var/qmail/supervise/spamd/run
cp /var/src/toaster-scripts-0.9.0/spamd.log.run /var/qmail/supervise/spamd/log/run
chmod 755 /var/qmail/supervise/spamd/run
chmod 755 /var/qmail/supervise/spamd/log/run
cp /var/src/toaster-scripts-0.9.0/local.cf /etc/mail/spamassassin/local.cf
mkdir /etc/mail/spamassassin/.spamassassin/
chown vpopmail /etc/mail/spamassassin/.spamassassin/
ln -s /var/qmail/supervise/spamd /service
Options
  • ClamAV
This open source virus scanner will be called by simscan.
NOTE: You need gmp-devel installed to verify the digital signatures of the virus database.
Install:
groupadd clamav
useradd -g clamav clamav
cd /var/src/tar
wget [url]http://shupp.org/software/clamav-0.90.2.tar.gz[/url]
wget [url]http://shupp.org/patches/clamav-0.90.2.patch[/url]
cd ../
tar -xzf tar/clamav-0.90.2.tar.gz
cd clamav-0.90.2
patch -p0 < ../tar/clamav-0.90.2.patch
./configure
make
make install-strip
# setup freshclam
touch /var/log/freshclam.log
chmod 600 /var/log/freshclam.log
chown clamav /var/log/freshclam.log
cp /var/src/toaster-scripts-0.9.0/freshclam /etc/init.d/freshclam
chmod 755 /etc/init.d/freshclam
ln -s ../init.d/freshclam /etc/rc0.d/K30freshclam
ln -s ../init.d/freshclam /etc/rc1.d/K30freshclam
ln -s ../init.d/freshclam /etc/rc2.d/S80freshclam
ln -s ../init.d/freshclam /etc/rc3.d/S80freshclam
ln -s ../init.d/freshclam /etc/rc4.d/S80freshclam
ln -s ../init.d/freshclam /etc/rc5.d/S80freshclam
ln -s ../init.d/freshclam /etc/rc6.d/K30freshclam
# add freshclam.log to logrotate
cp /var/src/toaster-scripts-0.9.0/freshclam.logrotate /etc/logrotate.d/freshclam
# run clamd under daemontools
mkdir -p /var/qmail/supervise/clamd/log
mkdir -p /var/log/clamd
chown clamav /var/log/clamd
cp ../toaster-scripts-0.9.0/clamd.run /var/qmail/supervise/clamd/run
cp ../toaster-scripts-0.9.0/clamd.log.run /var/qmail/supervise/clamd/log/run
chmod 755 /var/qmail/supervise/clamd/run
chmod 755 /var/qmail/supervise/clamd/log/run
# Start clamd and freshclam
ln -s /var/qmail/supervise/clamd /service
/etc/init.d/freshclam start
Options
  • ripmime
ripmime is a tool for extracting MIME p_w_uploads from email, and is used by simscan.
Install:
cd /var/src/tar
wget [url]http://shupp.org/software/ripmime-1.4.0.6.tar.gz[/url]
cd ..
tar -xzf tar/ripmime-1.4.0.6.tar.gz
cd ripmime-1.4.0.6
make
make install
Options
  • Simscan
Your qmail installation is already patched (qmail-queue patch) to support simscan, a new tool for using virus/spam scanners with qmail. The nice thing is that it prevents viruses (and optionally spam) from even getting into your queue. This is different from qmail-scanner, which will quarantine infected messages instead of stopping them at the SMTP level.
Install:
cd /var/src/tar
wget [url]http://shupp.org/software/simscan-1.3.1.shupp2.tar.gz[/url]
cd ../
tar -xzf tar/simscan-1.3.1.shupp2.tar.gz
cd simscan-1.3.1.shupp2
./configure --enable-user=clamav \
--enable-clamav=y \
--enable-spam=y \
--enable-spam-passthru=y \
--enable-per-domain=y \
--enable-ripmime \
--enable-attach=y \
--enable-received=y
make
make install-strip
# add default rules for simscan
echo ":clam=yes,spam=yes,spam_passthru=yes,attach=.vbs:.lnk:.scr:.wsh:.hta:.pif" > /var/qmail/control/simcontrol
# update /var/qmail/control/simcontrol.cdb
/var/qmail/bin/simscanmk
# put versions for received header in /var/qmail/control/simversions.cdb
/var/qmail/bin/simscanmk -g
# turn on scanning
echo ':allow,QMAILQUEUE="/var/qmail/bin/simscan"' &gt;&gt; ~vpopmail/etc/tcp.smtp
qmailctl cdb
  • TMDA
If you want the option to be very aggressive about spam control, TMDA (Tagged Message Delivery Agent) is a challenge based tool that requires a sender to confirm their sending address before the incoming message is delivered. I don't use it myself, but many people do.
Install:
cd /var/src/tar
wget [url]http://shupp.org/software/tmda-1.1.11.tgz[/url]
wget [url]http://shupp.org/software/tmda-cgi-0.16.3.tar.bz2[/url]
wget [url]http://shupp.org/patches/tmda-cgi-parent_re.patch[/url]
cd ../
tar -xzf tar/tmda-1.1.11.tgz
cd tmda-1.1.11
./compileall
cd ../
mv tmda-1.1.11 /usr/local/
ln -s /usr/local/tmda-1.1.11 /usr/local/tmda
# Now we'll install the vpopmail related scripts
cp /var/src/toaster-scripts-0.9.0/vadduser-tmda /home/vpopmail/bin/
cp /var/src/toaster-scripts-0.9.0/vpopmail-vdir.sh /home/vpopmail/bin/
cp /var/src/toaster-scripts-0.9.0/vtmdarc /home/vpopmail/etc/
# Setup tmda-ofmipd
mkdir -p /var/qmail/supervise/tmda-ofmipd/log
mkdir -p /var/qmail/supervise/tmda-ssl/log
mkdir /var/log/tmda-ofmipd/
mkdir /var/log/tmda-ssl/
chown vpopmail /var/log/tmda-*
cp /var/src/toaster-scripts-0.9.0/tmda-ofmipd.run /var/qmail/supervise/tmda-ofmipd/run
cp /var/src/toaster-scripts-0.9.0/tmda-ofmipd.log.run /var/qmail/supervise/tmda-ofmipd/log/run
# NOTE: If you are using stunnel version 4, you should use tmda.ssl.run.v4 instead of tmda-ofmipd.ssl.run below. Type 'stunnel -V' (v. 3) or 'stunnel -version' (v. 4) to see what version is installed. You will also need to copy over stunnel.conf like so: cp /var/src/toaster-scripts-0.9.0/tmda-stunnel.conf /var/qmail/supervise/tmda-ssl/stunnel.conf
cp /var/src/toaster-scripts-0.9.0/tmda-ofmipd.ssl.run /var/qmail/supervise/tmda-ssl/run
cp /var/src/toaster-scripts-0.9.0/tmda-ofmipd.ssl.log.run /var/qmail/supervise/tmda-ssl/log/run
chmod 755 /var/qmail/supervise/tmda-ofmipd/run
chmod 755 /var/qmail/supervise/tmda-ofmipd/log/run
chmod 755 /var/qmail/supervise/tmda-ssl/run
chmod 755 /var/qmail/supervise/tmda-ssl/log/run
ln -s /var/qmail/supervise/tmda-ofmipd /var/qmail/supervise/tmda-ssl /service/
# Setup tmda-cgi
cd /var/src
tar -xjf tar/tmda-cgi-0.16.3.tar.bz2
cd tmda-cgi-0.16.3
patch -p0 < ../tar/tmda-cgi-parent_re.patch
rm -r skel/uninstall/%\(Parent\)s/
cd ../
mv tmda-cgi-0.16.3 /usr/local/
cd /usr/local/tmda-cgi-0.16.3
./configure \
-t /var/www/cgi-bin/tmda.cgi \
-p /home/vpopmail/bin/vchkpw \
-m single-user \
-l "vpopmail1 /home/vpopmail/bin/vuserinfo ~" \
-i /usr/local/tmda-cgi-0.16.3/ \
-d /display
# NOTE: If you installed vpopmail somewhere other than /home/vpopmail, you'll need to update refernces in defaults.ini here
make
make install
chown vpopmail:vchkpw /var/www/cgi-bin/tmda.cgi
chmod ug+s /var/www/cgi-bin/tmda.cgi
o Now, you'll need to add an alias directive to your web server. Add the following to /etc/httpd/httpd.conf (or where ever your conf file is), and restart Apache:
Alias /display /usr/local/tmda-cgi-0.16.3/display/
Now, you should be able to point your browser to /cgi-bin/tmda.cgi, log in with your email address and password, and add/edit/remove tmda for your account. Note that the .qmail files created by tmda WILL show up in QmailAdmin.
Options
  • QmailMRTG7
This is a great tool for graphing your mail server's activity.
Install:
cd /var/src/tar
mkdir /var/www/html/qmailmrtg
wget [url]http://shupp.org/software/qmailmrtg7-4.2.tar.gz[/url]
wget [url]http://shupp.org/patches/qmailmrtg7-4.2-cfg.patch[/url]
cd ../
tar -xzf tar/qmailmrtg7-4.2.tar.gz
cd qmailmrtg7-4.2
patch -p0 &lt; ../tar/qmailmrtg7-4.2-cfg.patch
make
make install
# Edit qmail.mrtg.cfg and change all instances of FQDN to your hostname
cp qmail.mrtg.cfg /etc/
indexmaker --section=title /etc/qmail.mrtg.cfg > /var/www/html/qmailmrtg/index.html
# now run mrtg 3 times to get rid of initial cron errors
env LANG=C mrtg /etc/qmail.mrtg.cfg
env LANG=C mrtg /etc/qmail.mrtg.cfg
env LANG=C mrtg /etc/qmail.mrtg.cfg
o Add the following line to your crontab
0-55/5 * * * * env LANG=C /usr/bin/mrtg /etc/qmail.mrtg.cfg &gt; /dev/null
Options
  • QmailAdmin Limits
QmailAdmin can set per domain limits/defaults, which is really useful for hosting companies with different mail packages. This is covered in detail in the INSTALL file of qmailadmin (/var/src/qmailadmin-1.2.11/INSTALL).
 
 
Smtp 认证失效,用户名密码不正确
认证通不过,修改下面这个文件 ,将 -m 修改的大点儿
vim /var/qmail/supervise/qmail-smtpd/run
 
 
#!/bin/sh
QMAILDUID=`id -u vpopmail`
NOFILESGID=`id -g vpopmail`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
exec /usr/local/bin/softlimit -m 50000000 \