3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 03:49:27 +01:00
ergo/vendor/github.com/toorop/go-dkim
Shivaram Lingamneni 4f9d406b93 upgrade go-dkim
2020-11-08 17:56:46 -05:00
..
.gitignore fix #920, #921 2020-04-05 03:48:59 -04:00
dkim.go upgrade go-dkim 2020-11-08 17:56:46 -05:00
dkimHeader.go bump go-dkim 2020-06-01 00:40:30 -04:00
errors.go fix #920, #921 2020-04-05 03:48:59 -04:00
LICENSE fix #920, #921 2020-04-05 03:48:59 -04:00
pubKeyRep.go fix #920, #921 2020-04-05 03:48:59 -04:00
README.md fix #920, #921 2020-04-05 03:48:59 -04:00
watch fix #920, #921 2020-04-05 03:48:59 -04:00

go-dkim

DKIM package for Golang

GoDoc

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 (
    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

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)