Go client for SpamAssassin
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 88 commits ahead of saintienn:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github
bin
.gitignore
.travis.yml
Dockerfile
Gopkg.lock
Gopkg.toml
LICENSE
README.md
api.go
api_test.go
doc.go
example_test.go
sa_test.go
spamc.go
spamc_test.go

README.md

GoDoc Build Status codecov

spamc is a Go client library for SpamAssassin's spamd daemon.

It started out as a fork of saintienn/go-spamc with some fixes, but has since been completely rewritten.

Basic example:

// Connect
c := New("127.0.0.1:783", &net.Dialer{
    Timeout: 20 * time.Second,
})
ctx := context.Background()

msg := strings.NewReader("Subject: Hello\r\n\r\nHey there!\r\n")

// Check if a message is spam.
check, err := c.Check(ctx, msg, nil)
if err != nil {
    log.Fatal(err)
}
fmt.Println(check.Score)

// Report ham for training.
tell, err := c.Tell(ctx, msg, Header{}.
    Set("Message-class", "ham").
    Set("Set", "local"))
if err != nil {
    log.Fatal(err)
}
fmt.Println(tell)

See godoc for the full documentation.

Runnings tests

Use ./bin/test to run all tests; use ./bin/test -b testsa to run tests that require a running SpamAssassin instance. This will automatically run SA in a Docker container. You can also use the SPAMC_SA_ADDRESS to set the SA address.