|
4 years ago | |
---|---|---|
.gitignore | 5 years ago | |
LICENSE | 5 years ago | |
README.md | 4 years ago | |
dkim.go | 4 years ago | |
dkimHeader.go | 4 years ago | |
dkim_test.go | 4 years ago | |
errors.go | 4 years ago | |
pubKeyRep.go | 4 years ago | |
watch | 5 years ago |
Fork of toorop
's DKIM with non-pointer API and bugfixes.
go get github.com/andres-erbsen/go-dkim
Warning: you need to use Go 1.4.2-master or 1.4.3 (when it will be available) see https://github.com/golang/go/issues/10482 fro more info.
import (
dkim "github.com/andres-erbsen/go-dkim"
)
func main(){
// email is the email to sign (byte slice)
// privateKey the private key (pem encoded, byte slice )
dkim := dkim.NewDkim()
options := dkim.NewSigOptions()
options.PrivateKey = privateKey
options.Domain = "mydomain.tld"
options.Selector = "myselector"
options.SignatureExpireIn = 3600
options.BodyLength = 50
options.Headers = []string{"from", "date", "mime-version", "received", "received"}
options.AddSignatureTimestamp = true
options.Canonicalization = "relaxed/relaxed"
err := dkim.Sign(&email, options)
// handle err..
}
import (
dkim "github.com/toorop/go-dkim"
)
func main(){
// email is the email to verify (byte slice)
dkim := dkim.NewDkim()
_, err := dkim.Verify(email)
}