Spamd

Dec 16, 2013
1 min read
Jun 30, 2023 16:33 EEST

Installing it:

cd /usr/ports/mail/spamd
make install
make clean

Enable spamd in rc.conf:

  - enable spamd
obspamd_enable="YES"
obspamlogd_enable="YES"

Edit /etc/fstab:

  -  mount for spamd
fdescfs                 /dev/fd         fdescfs rw              0       0

and mount it with:

mount -a

Create the configuration file:

cd /usr/local/etc/spamd
cp spamd.conf.sample spamd.conf

We log the entries in a seperate file, edit /etc/syslog.conf for this:

!spamd
daemon.err;daemon.warn;daemon.info              /var/log/spamd

and restart it:

touch /var/log/spamd
chmod 644 /var/log/spamd
touch /usr/local/etc/mail/spamd-mywhite
chmod 644 /usr/local/etc/mail/spamd-mywhite
/etc/rc.d/syslogd restart

We enable log rotating by editing /etc/newsyslog.conf:

/var/log/spamd                          644  7     100  *     JC

and reload the config with:

/etc/rc.d/newsyslog restart

Now start it with:

/usr/local/etc/rc.d/obspamd start
/usr/local/etc/rc.d/obspamlogd start

Now we redirect the traffic by using pf. Make sure you have something like the following lines in your /etc/rc.conf:

# enable pf
pf_enable="YES"
pf_rules="/etc/pf.conf"
pf_flags=""
pflog_enable="YES"
pflog_logfile="/var/log/pflog"
pflog_flags=""

Now edit your /etc/pf.conf and add:

table <spamd-white> persist
table <spamd-mywhite> persist file "/usr/local/etc/mail/spamd-mywhite"

# redirect unkown mail sender to spamd
no rdr inet proto tcp from <spamd-white> to any \\
        port smtp
no rdr inet proto tcp from <spamd-mywhite> to any \\
        port smtp
rdr pass inet proto tcp from any to any \\
        port smtp -> 127.0.0.1 port spamd

and reload pf with:

/etc/rc.d/pf restart

Related Posts