Giter Club home page Giter Club logo

dspam-milter's Introduction

dspam-milter

pymilter-based daemon script to classify email using dspam daemon (and its dspamc client).

Main feature is that it is designed to never reject, drop or "quarantine" email, only add X-DSPAM-Result header (as returned by dspamc --deliver=summary).

User is assumed to be smart enough to e.g. add sieve rules to act upon this header (and maybe others, e.g. spf, dkim, ...) as they see fit.

All documented dspam setups seem to use either dspam as a delivery agent proxy or mail transport (with later mail re-injection), which assumes a lot of trust in that dspam process won't crash, fail to run proper delivery agent (or sendmail), be misconfigured or otherwise drop or mangle messages handled to it.

This script assumes no extra trust in dspam daemon, as any failure there will just result in X-DSPAM-Result header not being appended or TEMPFAIL result (with message generally left in queue) in case of script exception.

Another design principle is to use shipped "dspamc" client and not try to connect, authenticate over and implement DMTP or LMTP protocol to pass messages to a daemon, resulting in very simple and robust script (100-lines instead of e.g. 1k lines of pydspam).

Usage

Start the milter (--debug flag makes it more noisy):

./dspam-milter.py --debug local:/tmp/dspam_milter.sock

Add milter to postix configuration (main.cf):

smtpd_milters = unix:/tmp/dspam_milter.sock
non_smtpd_milters = unix:/tmp/dspam_milter.sock

Start dspam daemon and send reload signal to postfix daemon:

systemctl start dspam
systemctl reload postfix

Done!

Naturally, make sure milter socket, its umask and permissions are set correctly and postfix (or other MTA) can access it, but nothing else can.

See dspam-milter.py -h output for the list of additional CLI options.

Expected to be started from modern init like systemd, upstart, runit or whatever other process manager.

Extra tools

I use these for dspam setup maintenance.

dspam-train.py

Same as perl dspam_train (with --train option), but can navigate maildir++ (dovecot default, uses <maildir>/.folder.subfolder convention) paths to source several folders there as spam/ham, checking for message flags and timestamps to avoid processing too recent (since user weren't able to override verdict yet) or too old (to lessen load for large mailboxes) messages.

Also allows to test ham/spam folders for verdict mismatches without forcing dspam training (--test option).

Without --test or --train options, just builds index for stock dspam_train script's "-i" option (list of "[spam/ham] [filename]" lines), manual inspection or whatever other training module.

See dspam-train.py --help for more detailed list of options and operation modes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.