Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/toorop/go-dkim
DKIM package for golang
https://github.com/toorop/go-dkim
Last synced: 7 days ago
JSON representation
DKIM package for golang
- Host: GitHub
- URL: https://github.com/toorop/go-dkim
- Owner: toorop
- License: mit
- Created: 2015-04-29T15:38:27.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-01-03T09:29:56.000Z (12 months ago)
- Last Synced: 2024-10-25T04:10:11.947Z (about 2 months ago)
- Language: Go
- Size: 61.5 KB
- Stars: 98
- Watchers: 6
- Forks: 39
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - go-dkim - DKIM library, to sign & verify email. (Email / Search and Analytic Databases)
- awesome-go - go-dkim - DKIM package for golang - ★ 45 (Email)
- awesome-go-extra - go-dkim - 04-29T15:38:27Z|2020-11-03T13:16:31Z| (Email / Advanced Console UIs)
README
# go-dkim
DKIM package for Golang[![GoDoc](https://godoc.org/github.com/toorop/go-dkim?status.svg)](https://godoc.org/github.com/toorop/go-dkim)
## 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
```go
import (
dkim "github.com/toorop/go-dkim"
)func main(){
// email is the email to sign (byte slice)
// privateKey the private key (pem encoded, byte slice )
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..// And... that's it, 'email' is signed ! Amazing© !!!
}
```### Verify
```go
import (
dkim "github.com/toorop/go-dkim"
)func main(){
// email is the email to verify (byte slice)
status, err := Verify(&email)
// handle status, err (see godoc for status)
}
```## Todo
- [ ] handle z tag (copied header fields used for diagnostic use)