Categorygithub.com/teamwork/spamc
modulepackage
0.0.0-20200109085853-a4e0c5c3f7a0
Repository: https://github.com/teamwork/spamc.git
Documentation: pkg.go.dev

# README

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.

# Functions

New created a new Client instance.

# Structs

Client is a connection to the spamd daemon.
Error is used for spamd responses; it contains the spamd exit code.
Report contains the parsed results of the Report command.
ResponseCheck is the response from the Check command.
ResponseProcess is the response from the Process and Headers commands.
ResponseReport is the response from the Report and ReportIfSpam commands.
ResponseScore contains the Spam score of this email; used in various different responses.
ResponseSymbols is the response from the Symbols command.
ResponseTell is the response of a TELL command.

# Interfaces

Dialer to connect to spamd; usually a net.Dialer instance.

# Type aliases

Header for requests and responses.