toorop / go-dkim

DKIM package for golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use go-dkim

opened this issue · comments

Hello,

thank you for your work 💯

Can you please explain the usual way to use it in Go?

If i look at email-packages, they construct structs as emails, but you sign a []byte.

Whats now the usual packages / way to send this signed thing via system sendmail?

I can generate a []byte often via SliceForSigning := email.Bytes() for example, but than i have the old email object and the new signed? []byte.

Do you know a sample using any Go email package with go-dkim?


Just a sample what i mean:

        // using "github.com/jordan-wright/email"

	e := email.NewEmail()
	e.From = "Me <me@example.com>"
	e.To = []string{"test@example.com"}
	e.Subject = "dkim test"
	e.HTML = []byte("<h1>some HTML</h1>")

	byteSlice, err = e.Bytes()

	options := dkim.NewSigOptions()
	options.PrivateKey = privKey
	options.Domain = "domain.tld"
	options.Selector = "selector"
	options.SignatureExpireIn = 3600
	options.BodyLength = uint(len([]byte("<h1>some HTML</h1>")))
	options.Headers = []string{"from", "date", "mime-version", "received", "received"}
	options.AddSignatureTimestamp = true
	options.Canonicalization = "relaxed/relaxed"

	err = dkim.Sign(&byteSlice, options)

        // how to use signed []byte?

	e.Send("smtp.domain.tld:587", smtp.PlainAuth("", "name", "password", "smtp.domain.tld"))

Thank you

Hmm,

i did it just using Go 's smtp package, but,

if i only use

// "github.com/jordan-wright/email"

e := email.NewEmail()
e.From = "Me <me@domain.tld>"
e.To = []string{"one@example.com"}
e.Subject = "just a test"
e.HTML = []byte("<h1>some html</h1>")

e.Send("smtp.domain.tld:587", smtp.PlainAuth("", "me", "passwd", "smtp.domain.tld"))

i already have spf=pass, dkim=pass (and dmarc=pass) at Yahoo, Outlook and Gmail, without extra signing via go-dkim.

When to use go-dkim signing?

I like to close this issue already.