mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-23 12:29:25 +01:00
1.3 KiB
1.3 KiB
go-dkim
DKIM package for Golang
Getting started
Install
go get github.com/toorop/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.
Sign email
import (
"github.com/toorop/go-dkim"
dkim )
func main(){
// email is the email to sign (byte slice)
// privateKey the private key (pem encoded, byte slice )
:= 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"
options:= dkim.Sign(&email, options)
err // handle err..
// And... that's it, 'email' is signed ! Amazing© !!!
}
Verify
import (
"github.com/toorop/go-dkim"
dkim )
func main(){
// email is the email to verify (byte slice)
, err := Verify(&email)
status// handle status, err (see godoc for status)
}
Todo
- handle z tag (copied header fields used for diagnostic use)