Full Mail Server Solution w/ Virtual Domains & Users - Page 07 (Mail Delivery Server - DSPAM+Dovecot)

Want to support HowtoForge? Become a subscriber!
 
Submitted by Vecter (Contact Author) (Forums) on Wed, 2007-10-17 20:33. ::

E. Install Dovecot

So we're getting pretty far into our mail stack now... It has passed through the exchangers unharmed, DSPAM has gotten a hold of it, and now it needs to put it some where... but where? The answer is another service: Dovecot. Dovecot is an LDA (Local Delivery Agent), as well as a rather secure IMAP and POP3 server. As usual, Debian takes the majority of the work off our hands:

# apt-get install dovecot-imapd

For our purposes, we didn't need POP3 (and really, neither should you), but if you wanted it, just append dovecot-pop3d to the end of that command.

And that's it! Sure, there's still some Dovecot setup to do, but not yet... we just wanted it installed so that DSPAM would have a place to put our email. Let's go ahead and finish up the DSPAM install.

E. DSPAM Configuration

DSPAM is installed. DSPAM's MySQL Libraries are installed. Dovecot is (very minimally) installed. What's left? Well, while DSPAM is a truly incredible SPAM filter, it's not so incredible that it completely sets itself up. (Although let's be honest... give it a year, Debian will have it working ;) In the mean time, let's get this party started.

First, we need to make some changes in /etc/dspam/dspam.conf. This file contains all of the setup variables for DSPAM, and will tell it how to talk to the world.

/etc/dspam/dspam.conf

[...]
TrustedDeliveryAgent "/usr/libexec/dovecot/deliver -d %u"
[...]
UntrustedDeliveryAgent "/usr/libexec/dovecot/deliver -d %u"
[...]
QuarantineAgent "/usr/libexec/dovecot/deliver -d %u -m SPAM"
[...]
Debug *
[...]
Preference "spamAction=tag"
Preference "signatureLocation=message" # 'message' or 'headers'
Preference "showFactors=on"
Preference "spamSubject=[SPAM]"
[...]

You should also tell DSPAM about your local mail exchangers... this is dependent on your network setup, but for our scenario, MX-1.internal and MX-2.internal are 192.156.50.107 and 108, respectively.

[...]
LocalMX 192.168.50.107 192.168.50.108
[...]

Just a few more settings... remember, all of this can be found in the documentation, which you should read as often as possible!

[...]
Opt out
[...]
ParseToHeaders on
ChangeModeOnParse on
ChangeUserOnParse full
[...]

And finally, we need to tell the DSPAM daemon how to operate... we'll tell it to wait for LMTP connections on port 2424 (The 'unofficial' LMTP port is 24, but since it's unofficial, we're going to use the >1024 insecure area).

[...]
ServerPort 2424
ServerPID /var/run/dspam.pid
[...]
ServerMode standard
[...]
ServerParameters "--deliver=innocent, spam"
[...]

One last little debian-related setup to do. DSPAM can be run as either a daemon (Always running service) or as a program call. By default, it's setup as a program call, but we want the daemon to launch when the computer is booted. To change this, we need to change the value of START in /etc/default/dspam from "no" to "yes":

# Variables for dpam.
#
# Do not start dspam.
#START=no
#
# Changed for DSPAM Daemon #
START=yes
# User that runs dspam.
USER=dspam
# Options for dspam
#OPTIONS="--debug"

That will set DSPAM to start automatically at boot. To continue our install, we're going to start it manually:

# invoke-rc.d dspam start

And ~viola... DSPAM is now waiting for emails on port 2424 of postman.internal.example.com.


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.