Skip to content

Teamwork/spamc

 
 

Repository files navigation

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.

Releases

No releases published

Packages

No packages published

Languages

  • Go 86.1%
  • Shell 12.9%
  • Dockerfile 1.0%