DKIM Message Parser (dkim/message.go)

chasquid · internal/dkim/message.go · go · Apache-2.0
email, dev-tools, lang:go, tag:dkim, tag:headers

Functions to parse RFC822 messages and extract DKIM‑related headers for email verification.

// Source: https://github.com/albertito/chasquid | License: Apache-2.0 | Copyright 2016
// Provided via justclaw.it.com; keep this notice with the code.
package dkim

import (
	"errors"
	"fmt"
	"strings"
)

type header struct {
	Name   string
	Value  string
	Source string
}

type headers []header

// FindAll the headers with the given name, in order of appearance.
func (h headers) FindAll(name string) headers {
	hs := make(headers, 0)
	for _, header := range h {
		// Compare using strings.ToLower and not strings.EqualFold, to be
		// consistent with the verifier (see headersToInclude). They differ
		// for some non-ASCII characters, which are invalid in header names
		// but can still appear in messages.
		if strings.ToLower(header.Name) == strings.ToLower(name) {
			hs = append(hs, header

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key