Skip to content

toorop/go-dkim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Feb 26, 2025
9025cce · Feb 26, 2025

History

68 Commits
Apr 29, 2015
Apr 29, 2015
Jun 3, 2015
Feb 25, 2025
Jan 3, 2024
May 26, 2020
Feb 25, 2025
Dec 11, 2015
Aug 20, 2019
Aug 20, 2019
May 11, 2015

Repository files navigation

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 golang/go#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)

About

DKIM package for golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages