func SanitizeMessage(parsed ParsedMessage, cfg *Config) error {
	if bytes.Index(*parsed.Bytes, []byte{13, 10, 13, 10}) < 0 {
		*parsed.Bytes = bytes.Replace(*parsed.Bytes, []byte{10}, []byte{13, 10}, -1)
	}
	removedHeaders := []string{"Date", "Message-ID", "BCC"}
	for _, h := range removedHeaders {
		RemoveHeader(parsed.Bytes, h)
	}
	header := "Date: " + time.Now().Truncate(15*time.Minute).UTC().Format(time.RFC1123Z) + "\r\n"
	*parsed.Bytes = append([]byte(header), *parsed.Bytes...)
	header = "Message-ID: <" + parsed.Hash() + "@" + parsed.SourceDomain + ">\r\n"
	*parsed.Bytes = append([]byte(header), *parsed.Bytes...)
	m, err := mail.ReadMessage(bytes.NewReader(*parsed.Bytes))
	if err != nil {
		return err
	}
	parsed.Message = m
	return nil
}
SanitizeMessage takes a byte buffer of an Email message, along with configuration
for the sending domain, and uses these to transform the message into one that is
more privacy preserving - in particular by quantizing identifying dates and
message IDs. The byte buffer of the message is modified in-place.
package lib
import (
	"bytes"
	"log"
	"net/mail"
	"os/exec"
	"strings"
	"time"
	dkim "github.com/toorop/go-dkim"
)
func RemoveHeader(msg *[]byte, header string) {
	if bytes.Index(*msg, []byte{13, 10, 13, 10}) < 0 {
		*msg = bytes.Replace(*msg, []byte{10}, []byte{13, 10}, -1)
	}
	startPtr := 0
	endPtr := bytes.Index(*msg, []byte{13, 10, 13, 10})
	if endPtr == -1 {
		log.Fatal("couldn't locate end of headers.")
	}
	out := make([]byte, 0, len(*msg))
	match := []byte(header + ":")
	for startPtr < endPtr {
		nextPtr := bytes.Index((*msg)[startPtr:], []byte{13, 10}) + 2
		for (*msg)[startPtr+nextPtr] == byte(' ') || (*msg)[startPtr+nextPtr] == byte('	') {
			nextPtr = nextPtr + bytes.Index((*msg)[startPtr+nextPtr:], []byte{13, 10}) + 2
		}
		if !bytes.HasPrefix((*msg)[startPtr:], match) {
			out = append(out, (*msg)[startPtr:startPtr+nextPtr]...)
		}
		startPtr += nextPtr
	}
	out = append(out, (*msg)[endPtr:]...)
	*msg = out
}