Filtering spam mails with bogofilter
22.03.2020 by Dirk OlmesI’m running a Postfix server here at home to process incoming mail. To integrate spam filtering I’m delivering mails via procmail - it’s as simple as setting mailbox_command = /usr/bin/procmail
in postfix’ main.cf
.
Spam filtering works by invoking the filter (bogofilter in my case) from procmail like this:
:0 fw
| /usr/bin/bogofilter -uep
This command will pipe the mail content through bogofilter which will add a X-Bogosity
header denoting the spam status of the mail.
A second procmail rule moves all spam to a designated spam folder on my IMAP server:
:0
* ^X-Bogosity: Spam.*
$HOME/.maildir/.INBOX.Spam/
For training I use two designated folders on my IMAP server: LearnSpam and LearnGood. I’m simply moving mails that I want to train as spam to the LearnSpam folder. Once per hour I train spam/good mails using this script:
#!/bin/bash
SPAM_FOLDER=$HOME/.maildir/.INBOX.Spam.LearnSpam
if [[ -d $SPAM_FOLDER ]]; then
SPAM_CUR=$SPAM_FOLDER/cur
# only invoke bogofilter if there are mails in the folder
if [[ "$(ls -A $SPAM_CUR)" ]]; then
/usr/bin/bogofilter -s -B $SPAM_FOLDER && rm $SPAM_CUR/*
fi
fi
HAM_FOLDER=$HOME/.maildir/.INBOX.Spam.LearnGood
if [[ -d $HAM_FOLDER ]]; then
HAM_CUR=$HAM_FOLDER/cur
# only invoke bogofilter if there are mails in the folder
if [[ "$(ls -A $HAM_CUR)" ]]; then
/usr/bin/bogofilter -n -B $HAM_FOLDER && rm $HAM_CUR/*
fi
fi
The script is invoked via cron.
Fixing the dreaded “problem with defaults entries” in debian
At work we host a number of Debian VMs. Most of them are integrated into the central active directory server using the sssd package.
Quite unrelatedly my boss kept nagging me about incoming emails to root that looked like this
Subject: *** SECURITY information for <host> ***
<host> : Sep 29 05:45 …
Chromecasting using a custom Chromium build
Setting up a software RAID1
I’m helping a friend to set up a machine with Gentoo. This will be a machine to host production applications and it is equipped with 2 identical hard drives. I will set up a software RAID 1. This has been a life saver on a similar machine before where …
read moreGenkernel with virtio drivers
A colleague asked me to help analyze problems migrating a Gentoo guest VM from a Xen Server based host to a Proxmox (KVM based) host. The Gentoo VM would not boot beyond the initramfs - it just died saying that the root device could not be found.
Since the VM itself …
read moreEnabling “Show in System Explorer” in Eclipse on Linux
On my Gentoo machine the “Show in System Explorer” menu item did not work on Eclipse. I kept getting this error message:
Execution of 'dbus-send --print-reply --dest=org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems array:string:"file:/tmp/HelloWorld.java" string:""' failed with return code: 1
A …
read moreLinux Mint update from 17.2 to 17.3
At work we use Linux Mint for some virtual machines that need a desktop environment. Recently, the Linux Mint project released a fairly major update to 17.3. At fist, they did not offer an update for an existing system but promised to release that laster.
Now, a good while …
read moreNFS setup
I’m planning to put my Raspberry Pi back to use. I have always disliked its dependency on SD memory cards so I’m planning to put the Pi’s root filesystem on NFS. The Pi side will be a topic for another blog post later, first I’ll have …
read morespeeding up portage’s metadata cache
Gentoo’s portage keeps metadata about installed ebuilds in /var/cache/edb
. Dependency info for all installed ebuilds is in a dep
subdirectory which typically looks something like this:
.
├── usr
│ └── portage
│ ├── app-admin
│ │ ├── eselect-1.4.1
│ │ ├── eselect-lib-bin-symlink-0.1.1
│ │ ├── eselect-opengl-1.2.7
│ │ ├── gamin-0.1.10-r1
│ │ ├── logrotate-3.8.7
│ │ └── perl-cleaner-2.16
...
When …
read moreexaile vs. gstreamer
My favourite music player app on Linux is Exaile. On Gentoo it’s available straight from portage but getting playback working for different audio formats its not quite straightforward.
Exaile depends on gstreamer - albeit not on the latest version but on the 0.10 version line. Since Gentoo supports slotted …
read more