Postfix Clamav Dspam Courier HOGYAN

A HupWiki-ből...

Tartalomjegyzék

Bevezető

Jelen leírás ubuntu 5.10-hez ad segítséget.
Ubuntu server telepítést használtam.

PostgreSql-t használok (mert én ebben bízok :) ), de a rendszer használható mysql-el is.

A levél terveink szerint a következő útvonalat fogja bejárni:

postfix[25]-> amavis[10024] -> postfix[10025]-> dspam[10026] -> postfix[10027] -> maildop -> courier imap/pop3

Képességek

  • Több domain kezelése
  • Virtuális userek
  • User quota
  • Vírusszűrés
  • Spam Szűrés
  • Imap / Pop3 hozzáférés
  • Authentikált smtp szolgáltatás
  • Secure smtp (TLS)

Összetevők

postfix, amavis, clamav, dspam, courier (imap/pop/maildrop), postgresql

Kezdő lépések

Hozzunk létre egy új felhasználót, ennek a nevében lesznek tárolva a levelek..

sudo adduser --no-create-home --system  --disabled-login vmail

Készítsük el a maildir-ek tárolókönyvtárát.

sudo mkdir -p /var/virtuals/mail
sudo chown -R vmail:users /var/virtuals/mail

Ha még nem módosítottuk idáig a /etc/apt/sources.list file-t akkor tegyük meg.

deb http://us.archive.ubuntu.com/ubuntu breezy main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu breezy main restricted universe multiverse

deb http://us.archive.ubuntu.com/ubuntu breezy-updates main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu breezy-updates main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu breezy-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu breezy-security main restricted universe multiverse

deb http://debian.linuxia.de/ courier-test main

Majd

sudo apt-get update
sudo apt-get upgrade

Postgresql telepítése

apt-get install postgresql-8.0 postgresql-client-8.0 postgresql-common postgresql-contrib-8.0

Postgresql beállítása

Állítsuk be a localhost kapcsolatot....
Szerkesszük a /etc/postgresql/8.0/main/pg_hba.conf file-t.

host    all         all         127.0.0.1     255.255.255.255    password

Szerkesszük a /etc/postgresql/8.0/main/postgresql.conf file-t, és az ssl- állítsuk false-ra

ssl = false

Indítsuk ujra a szervert

sudo /etc/init.d/postgres restart

Hozzunk létre egy adatbázis usert, mondjuk isp_mail néven:

sudo -u postgres createuser isp_mail --no-adduser --createdb --pwprompt

Késöbb majd megvonjuk a jogokat...
Hozzuk létre az adtabázist:

createdb --encoding UNICODE --owner isp_mail --host 127.0.0.1 --username=isp_mail --password

Majd adjunk hozzá plpgsql-t

createlang --dbname=isp_mail --username=isp_mail -W plpgsql --host 127.0.0.1

Postfix telepítése

apt-get install postfix postfix-pcre postfix-pgsq


Postfix configurálása

/etc/postfix/main.cf

smtpd_banner = $myhostname ESMTP $mail_name
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

recipient_delimiter = +

#address rewrite
swap_bangpath = no
allow_percent_hack = no

##############################################################################
#                              network conf
##############################################################################

myorigin = /etc/mailname
mydestination = localhost.localdomain, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8
inet_interfaces = all

##############################################################################
#                              smtp restrictions
##############################################################################

strict_rfc821 = yes

smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_rbl_client relays.ordb.org, reject_rbl_client opm.blitzed.org,
smtpd_sender_restrictions =
smtpd_recipient_restrictions =  permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
smtpd_client_restrictions =  permit_mynetworks, reject_rbl_client relays.ordb.org, reject_rbl_client opm.blitzed.org, reject_rbl_client list.
##############################################################################
#                              email restrictions
##############################################################################

# maximum email size  20 MB
message_size_limit = 20971520
header_checks = pcre:/etc/postfix/header_checks
body_checks = pcre:/etc/postfix/body_checks


##############################################################################
#                              local mail
##############################################################################

myhostname = localhost.localdomain
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases


##############################################################################
#                              virtual mail
##############################################################################

transport_maps = pgsql:/etc/postfix/sql-transport.cf
virtual_mailbox_domains = pgsql:/etc/postfix/sql-virtual-domains.cf
virtual_mailbox_maps = pgsql:/etc/postfix/sql-virtual-mailbox.cf
virtual_alias_maps = pgsql:/etc/postfix/sql-virtual-alias.cf

maildrop_destination_recipient_limit = 1
virtual_mailbox_base = /
home_mailbox = Maildir/

#vmail uid, users gid 
virtual_minimum_uid = 106
virtual_uid_maps = static:106
virtual_gid_maps = static:100


##############################################################################
#                              smtp auth
##############################################################################

# Enable SMTP authentication support
smtp_sasl_auth_enable = no
smtpd_sasl2_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $mydomain, localhost, $myhostname
unknown_local_recipient_reject_code = 450


smtpd_use_tls = yes
#smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/postfix/ssl/cert.pem
smtpd_tls_key_file = /etc/postfix/ssl/privkey.pem
#smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom

/etc/postfix/master.cf

#
# Postfix master process configuration file.  For details on the format
# of the file, see the Postfix master(5) manual page.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
#smtp      inet  n       -       -       -       -       smtpd
#submission inet n      -       -       -       -       smtpd
#       -o smtpd_etrn_restrictions=reject
#       -o smtpd_client_restrictions=permit_sasl_authenticated,reject
smtps    inet  n       -       -       -       -       smtpd
  -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes
#submission inet n      -       -       -       -       smtpd
#  -o smtpd_etrn_restrictions=reject
#  -o smtpd_enforce_tls=yes -o smtpd_sasl_auth_enable=yes
#628      inet  n       -       -       -       -       qmqpd
pickup    fifo  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      fifo  n       -       -       300     1       qmgr
#qmgr     fifo  n       -       -       300     1       oqmgr
tlsmgr    unix  -       -       -       1000?   1       tlsmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
smtp      unix  -       -       -       -       -       smtp
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay     unix  -       -       -       -       -       smtp
        -o fallback_relay=
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       -       -       -       lmtp
anvil     unix  -       -       -       -       1       anvil
scache    unix  -       -       -       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
#maildrop  unix  -       n       n       -       -       pipe
#  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# See the Postfix UUCP_README file for configuration details.
#
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -       n       n       -       2       pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       -       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

# ======================================================================
# Amavis + DSPAM
# ======================================================================
#
smtp                 inet      n      -      n      -      -      smtpd
    -o content_filter=smtp-amavis:[127.0.0.1]:10024

smtp-amavis unix -      -       n       -       2  lmtp
    -o lmtp_data_done_timeout=1200
    -o lmtp_send_xforward_command=yes

:10025          inet            n       -       n       -       -       smtpd
    -o content_filter=lmtp:127.0.0.1:10026
    -o lmtp_destination_concurrency_limit=5
    -o smtpd_client_restrictions=
    -o smtpd_helo_restrictions=
    -o smtpd_sender_restrictions=
    -o smtpd_error_sleep_time=0
    -o smtpd_recipient_restrictions=permit_mynetworks,reject
    -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks

:10027          inet            n       -       n       -       -       smtpd
    -o content_filter=
    -o smtpd_client_restrictions=
    -o smtpd_helo_restrictions=
    -o smtpd_sender_restrictions=
    -o smtpd_error_sleep_time=0
    -o smtpd_recipient_restrictions=permit_mynetworks,reject
    -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks

maildrop        unix            -       n       n       -       -       pipe
        flags=DRhu user=vmail
        argv=/usr/bin/maildrop -w 80 -d ${recipient}

/etc/postfix/header_checks

/^Content-(Disposition|Type):\s+.+?(?:file)?name="?.+?\.(386|ad[ept]|app|as[dpx]|ba[st]|bin|btm|cab|cbt|cgi|chm|cil|cla(ss)?|cmd|cp[el]|crt|cs[chs]|cvp|dll|dot|drv|ex[_e]|fon|fxp|hlp|ht[ar]|in[fips]|isp|jar|jse?|keyreg|ksh|lib|lnk|md[abetw]|mht(m|ml)?|ms[ciopt]|nte|nws|obj|ocx|ops|ov.|pcd|pgm|pif|p[lm]|pot|prg|reg|sc[rt]|sh[bs]?|slb|smm|sw[ft]|sys|url|vb[esx]?|vir|vmx|vxd|wm[dsz]|ws[cfh]|xms|\{[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}\})\b/    REJECT ".$2" file attachment types not allowed

/etc/postfix/body_checks

#exe fileokat nem engedünk
/^TV[nopqr]....[AB]..A.A/i  REJECT Email with EXE files attached denied
/^M35[GHIJK].`..`..*````/i  REJECT Email with EXE files attached denied

# Skip further analysis of base64-encoded lines
# See: http://www.fourmilab.ch/webtools/base64/rfc1341.html
/^[A-Za-z0-9+\/=]{4,76}$/       OK

# Skip pflogsumm report lines
/^ {6,11}\d{1,6}[ km] / OK
/^ {4}blocked using /   OK

/^begin\s+\d+\s+.+?\.(386|ad[ept]|app|as[dpx]|ba[st]|bin|btm|cab|cbt|cgi|chm|cil|cla(ss)?|cmd|com|cp[el]|crt|cs[chs]|cvp|dll|dot|drv|ex[_e]|fon|fxp|hlp|ht[ar]|in[fips]|isp|jar|jse?|keyreg|ksh|lib|lnk|md[abetw]|mht(m|ml)?|ms[ciopt]|nte|nws|obj|ocx|ops|ov.|pcd|pgm|pif|p[lm]|pot|prg|reg|sc[rt]|sh[bs]?|slb|smm|sw[ft]|sys|url|vb[esx]?|vir|vmx|vxd|wm[dsz]|ws[cfh]|xms|\{[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}\})\b/      REJECT ".$1" filetype not allowed

Hozzuk létre a /etc/postfix/ssl könyvtárat és készítsük el a kulcsokat...

sudo mkdir /etc/postfix/ssl
cd /etc/postfix/ssl
sudo openssl req -new -x509 -nodes -out cert.pem

Majd jöjjenek az sql lookup-ok...
/etc/postfix/sql-transport.cf

user = vmail
password = databasepassword
dbname = isp_mail
hosts = localhost
query = SELECT transport FROM mail_transports WHERE domain='%s' AND active='true'

/etc/postfix/sql-virtual-alias.cf

user = vmail
password = databasepassword
dbname = isp_mail
hosts = localhost
query = SELECT destinations FROM mail_aliasses WHERE email_address='%s' AND active='true'

/etc/postfix/sql-virtual-domains.cf

user = vmail
password = databasepassword
dbname = isp_mail
hosts = localhost
query = SELECT domain FROM mail_domains WHERE domain='%s' AND active='true'

/etc/postfix/sql-virtual-mailbox.cf

user = vmail
password = databasepassword
dbname = isp_mail
hosts = localhost
query = SELECT maildir FROM mail_mailbox WHERE email_address='%s' AND active='true'

/etc/postfix/sasl/smtpd.conf

pwcheck_method: auxprop
auxprop_plugin: sql
password_format: plain
sql_engine: pgsql
sql_hostnames: localhost
sql_user: vmail
sql_passwd: databasepassword
sql_database: isp_mail
sql_select: select clearpasswd from mail_mailbox where email_address='%u@%r' and smtp_active='true'

Vonjuk vissza a jogokat.

sudo chmod 600 /etc/postfix/sql-transport.cf
sudo chmod 600 /etc/postfix/sql-virtual-alias.cf
sudo chmod 600 /etc/postfix/sql-virtual-domains.cf
sudo chmod 600 /etc/postfix/sql-virtual-mailbox.cf
sudo chmod 600 /etc/postfix/sasl/smtpd.conf

sudo chown postfix /etc/postfix/sql-transport.cf
sudo chown postfix /etc/postfix/sql-virtual-alias.cf
sudo chown postfix /etc/postfix/sql-virtual-domains.cf
sudo chown postfix /etc/postfix/sql-virtual-mailbox.cf

Hozzuk létre a táblákat az isp_mail adatbázisban:

CREATE TABLE mail_aliasses (
    id serial NOT NULL,
    email_address character varying(255) NOT NULL,
    destinations text NOT NULL,
    active boolean DEFAULT true NOT NULL
);

CREATE TABLE mail_domains (
    id serial NOT NULL,
    "domain" character varying(255) NOT NULL,
    active boolean DEFAULT true NOT NULL
);

CREATE TABLE mail_mailbox (
    id serial NOT NULL,
    email_address character varying(255) NOT NULL,
    "password" character varying(128) NOT NULL,
    clearpasswd character varying(128),
    uid integer NOT NULL,
    gid integer NOT NULL,
    home character varying(255) NOT NULL,
    maildir character varying(255) NOT NULL,
    quota character varying(255) NOT NULL,
    active boolean DEFAULT true NOT NULL,
    smtp_active boolean DEFAULT true NOT NULL
);

CREATE TABLE mail_transports (
    id serial NOT NULL,
    "domain" character varying(255) NOT NULL,
    transport character varying(255) NOT NULL,
    active boolean DEFAULT true NOT NULL
);

Amavis telepítése

sudo apt-get install amavisd-new

Amavis configurálása

/etc/amavis/amavisd.conf

értelemszerűen írjuk át...

$mydomain = 'example.com';

Clamav antivírus telepítése

sudo apt-get install clamav clamav-base clamav-daemon clamav-freshclam arj unzoo unzip zip unrar-nonfree


Clamav antivírus configurálása

/etc/clamav/clamd.conf

LocalSocket /var/run/clamav/clamd.ctl
FixStaleSocket
User clamav
AllowSupplementaryGroups
ScanMail
ScanArchive
ArchiveMaxRecursion 5
ArchiveMaxFiles 1000
ArchiveMaxFileSize 20M
ArchiveMaxCompressionRatio 250
ScanRAR
MaxDirectoryRecursion 25
ReadTimeout 180
MaxThreads 12
MaxConnectionQueueLength 15
StreamMaxLength 20M
LogFile /var/log/clamav/clamav.log
LogTime
LogFileMaxSize 0
PidFile /var/run/clamav/clamd.pid
DatabaseDirectory /var/lib/clamav
SelfCheck 3600

Dspam telepítése

Sajnos ez csak forrásból megy jelenleg.
Csináltam belőle deb-et, aki lusta használja azt: dspam-3.6.1.tar.gz dspam_3.6.1-1_i386.deb
Biztos ami ziher belefordítottam a mysql, sqlite, db4 és hash támogatást is.
A fordítás configja:

dh_make
cd debian
mcedit rules
STORAGE="libdb4_drv,mysql_drv,pgsql_drv,sqlite3_drv,hash_drv"

CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" ./configure \
                                    --host=$(DEB_HOST_GNU_TYPE) \
                                    --build=$(DEB_BUILD_GNU_TYPE) \
                                    --prefix=/usr \
                                    --sysconfdir=/etc/dspam \
                                    --mandir=\$${prefix}/share/man \
                                    --infodir=\$${prefix}/share/info \
                                    --libdir='$${prefix}/lib/dspam' \
                                    --with-dspam-home=/var/spool/dspam \
                                    --with-logdir=/var/log/dspam \
                                    --enable-domain-scale \
                                    --with-storage-driver=$(STORAGE) \
                                    --with-mysql-includes=/usr/include/mysql \
                                    --with-pgsql-includes=`pg_config --includedir` \
                                    --enable-daemon \
                                    --enable-virtual-users \
                                    --enable-preferences-extension \
                                    --disable-mysql4-initialization \
                                    --enable-debug \
                                    --enable-clamav \
                                    --enable-delivery-to-stdout \
                                    --enable-spam-delivery

debian/rules binary-arch

telepítése:

sudo dpkg -i dspam_3.6.1-1_i386.deb

Dspam configurálása

/etc/dspam/dspam.conf

Home /var/spool/dspam
StorageDriver /usr/lib/dspam/libpgsql_drv.so

# --- PostgreSQL ---

PgSQLServer     127.0.0.1
PgSQLPort       5432
PgSQLUser       isp_mail
PgSQLPass       databasepassword
PgSQLDb         isp_mail
PgSQLConnectionCache    3
PgSQLVirtualTable          dspam_virtual_uids
PgSQLVirtualUIDField       uid
PgSQLVirtualUsernameField  username


DeliveryHost        127.0.0.1
DeliveryPort        10027
DeliveryIdent       localhost
DeliveryProto       SMTP

ServerPort              10026
ServerQueueSize         32
ServerPID              /var/run/dspam/dspam.pid
ServerMode              standard
#ServerParameters       "--deliver=innocent,spam -d %u"
ServerParameters       "--deliver=innocent,spam -d %u"
ServerIdent            "dspam-in"

OnFail error

TrustedDeliveryAgent "/usr/bin/maildrop"
TrustedDeliveryAgent "/usr/bin/procmail"

Trust root
Trust mail
Trust vmail
Trust daemon

TrainingMode notrain
TestConditionalTraining on
Feature chained
Feature tb=5
Feature whitelist

Algorithm graham burton
PValue graham

Preference "spamAction=tag"
Preference "signatureLocation=headers"  # 'message' or 'headers'
Preference "showFactors=on"

AllowOverride trainingMode
AllowOverride spamAction spamSubject
AllowOverride statisticalSedation
AllowOverride enableBNR
AllowOverride enableWhitelist
AllowOverride signatureLocation
AllowOverride showFactors
AllowOverride optIn optOut
AllowOverride whitelistThreshold

# --- Hash ---
HashRecMax              100000
HashAutoExtend          on
HashMaxExtents          0
HashExtentSize          50000
HashMaxSeek             100
Notifications   on

PurgeSignatures 14          # Stale signatures
PurgeNeutral    90          # Tokens with neutralish probabilities
PurgeUnused     90          # Unused tokens
PurgeHapaxes    30          # Tokens with less than 5 hits (hapaxes)
PurgeHits1S     15          # Tokens with only 1 spam hit
PurgeHits1I     15          # Tokens with only 1 innocent hit

LocalMX 127.0.0.1
SystemLog on
UserLog   on
Opt out

ProcessorBias on

Hozzuk létre az adattáblákat:

CREATE TABLE dspam_token_data (
  uid smallint,
  token bigint,
  spam_hits int,
  innocent_hits int,
  last_hit date,
  UNIQUE (uid, token)
) WITHOUT OIDS;

CREATE TABLE dspam_signature_data (
  uid smallint,
  signature varchar(128),
  data bytea,
  length int,
  created_on date,
  UNIQUE (uid, signature)
) WITHOUT OIDS;

CREATE TABLE dspam_stats (
  uid smallint PRIMARY KEY,
  spam_learned int,
  innocent_learned int,
  spam_misclassified int,
  innocent_misclassified int,
  spam_corpusfed int,
  innocent_corpusfed int,
  spam_classified int,
  innocent_classified int
) WITHOUT OIDS;

CREATE TABLE dspam_neural_data (
  uid smallint,
  node smallint,
  total_correct int,
  total_incorrect int,
  UNIQUE (node, uid)
) WITHOUT OIDS;

CREATE INDEX id_neural_data_01 ON dspam_neural_data(uid);

CREATE TABLE dspam_neural_decisions (
  uid smallint,
  signature varchar(128),
  data bytea,
  length int,
  created_on date,
  UNIQUE (signature, uid)
) WITHOUT OIDS;

CREATE TABLE dspam_preferences (
  uid smallint,
  preference varchar(128),
  value varchar(128),
  UNIQUE (uid, preference)
) WITHOUT OIDS;

create function lookup_tokens(integer,bigint[])
  returns setof dspam_token_data
  language plpgsql stable
  as '
declare
  v_rec record;
begin
  for v_rec in select * from dspam_token_data
                where uid=$1
                  and token in (select $2[i]
                                  from generate_series(array_lower($2,1),
                                                       array_upper($2,1)) s(i))
  loop
    return next v_rec;
  end loop;
  return;
end;';

CREATE SEQUENCE dspam_virtual_uids_seq;

CREATE TABLE dspam_virtual_uids (
  uid smallint DEFAULT nextval('dspam_virtual_uids_seq') PRIMARY KEY,
  username varchar(128)
) WITHOUT OIDS;

CREATE UNIQUE INDEX id_virtual_uids_01 ON dspam_virtual_uids(username);
CREATE UNIQUE INDEX id_virtual_uids_02 ON dspam_virtual_uids(uid);

Hozzuk létre a /var/spool/dspam/group file-t, a következő tartalommal.

global:merged:*
classifictiongroup:classification:*global
inoculationgroup:inocoulation:*global

Így a levelek elemzésekor figyelembevesszük a globális spam adatokat is.

Hozzuk létre az init scriptet:
/etc/init.d/dspam

#!/bin/sh
# Start/stop the dspam daemon.

test -f /usr/bin/dspam || exit 0


. /lib/lsb/init-functions
DAEMON=/usr/bin/dspam
ARGS=--daemon
PIDFILE=/var/run/dspam/dspam.pid
USER=vmail
case "$1" in
start)  log_begin_msg "Starting dspam daemon..."
        start-stop-daemon --start --quiet --exec $DAEMON --pidfile $PIDFILE  --name dspam --chuid $USER --group daemon -b -- $ARGS
        log_end_msg $?
        ;;
stop)   log_begin_msg "Stopping dspam daemon..."
        start-stop-daemon --stop --quiet --pidfile $PIDFILE --name dspam
        log_end_msg $?
        ;;
restart) log_begin_msg "Restarting dspam daemon..."
        start-stop-daemon --stop --retry 5 --quiet --pidfile $PIDFILE --name dspam
        start-stop-daemon --start --quiet --exec $DAEMON --pidfile $PIDFILE  --name dspam --chuid $USER --group daemon -b -- $ARGS
        log_end_msg $?
        ;;
*)      log_success_msg "Usage: /etc/init.d/dspam start|stop|restart"
        exit 1
        ;;
esac
exit 0

Adjuk át a vmail usernek a szükséges könyvárakat, file-okat:

sudo mkdir /var/run/dspam
sudo chown vmail:daemon /var/run/dspam
sudo chown -R vmail:daemon /var/spool/dspam/
sudo chown vmail:daemon /etc/dspam/dspam.conf
sudo chmod 600 /etc/dspam/dspam.conf

Dspam tanítása

global tanítás spamre

dspam --user global --class=spam --mode=teft --source=corpus < spamlevel

global tanítás nem spamre :)

dspam --user global --class=innocent --mode=teft --source=corpus < nemspamlevel

egy user tanítása spamre

dspam --user user@valahol.com --class=spam --mode=teft --source=corpus < spamlevel

egy user tanítása nem spamre :)

dspam --user user@valahol.com --class=innocent --mode=teft --source=corpus < nemspamlevel

Courier telepítése

sudo apt-get install courier-authdaemon courier-base courier-authpostgresql courier-maildrop courier-imap courier-pop

Courier configurálása

/etc/courier/authdaemonrc

authmodulelist="authpgsql"
authmodulelistorig="authpgsql authpam"
daemons=5
version=""
authdaemonvar=/var/run/courier/authdaemon

/etc/courier/authpgsqlrc

# DATABASE CONNECT
PGSQL_HOST              localhost
PGSQL_PORT              5432
PGSQL_USERNAME          vmail
PGSQL_PASSWORD          databasepassword
PGSQL_DATABASE          isp_mail

PGSQL_USER_TABLE        mail_mailbox
PGSQL_LOGIN_FIELD       email_address
PGSQL_CRYPT_PWFIELD     password
PGSQL_CLEAR_PWFIELD     clearpasswd
PGSQL_UID_FIELD         uid
PGSQL_GID_FIELD         gid
PGSQL_HOME_FIELD        home
PGSQL_QUOTA_FIELD       quota
PGSQL_WHERE_CLAUSE      active='y'

TODO

bevezetés részletezése
maildroprc
maildir create
felhasználók felvétele, állítgatása
domainok kezelése
autoreplay szolgáltatás

Még sok todo jön :)