Skip to content

Enmime Migration Guide

James Hillyerd edited this page May 20, 2018 · 5 revisions

Things you will likely need to update in your code:

Import

import "github.com/jhillyerd/go.enmime"

becomes:

import "github.com/jhillyerd/enmime"

Envelope

msg, err := mail.ReadMessage(reader)
var body *enmime.MIMEBody
body, err = enmime.ParseMIMEBody(msg)

becomes:

var env *enmime.Envelope
env, err = enmime.ReadEnvelope(reader)

Part

var part *enmime.MIMEPart
part, err = enmime.ParseMIME(reader)
from := part.Header().Get("From")

becomes:

var part *enmime.Part
part, err = enmime.ReadParts(reader)
from := part.Header.Get("From")

Part Content

Both versions of enmime would decode (base64 or quoted-printable) the content prior to making it available to clients. The new version also converts content to UTF-8 if it can determine the character set.

var content []byte
content = part.Content()
// or
writer.Write(part.Content())

becomes:

var content []byte
part = part.Content
// or
writer.Write(part.Content)
Clone this wiki locally