DKIM package for golang
Switch branches/tags
Nothing to show
Clone or download
toorop Merge pull request #6 from k33nice/master
Prevent panic on type conversion
Latest commit 8367202 Dec 3, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Apr 29, 2015
LICENSE Initial commit Apr 29, 2015
README.md Typo Jun 3, 2015
dkim.go fix: #1 Dec 11, 2015
dkimHeader.go Update dkimHeader.go Oct 12, 2017
dkim_test.go add signedBadAFlag Feb 13, 2017
errors.go fix: #2 Dec 11, 2015
pubKeyRep.go Prevent panic on type conversion Dec 2, 2017
watch new signature fro sign May 11, 2015

README.md

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)