Categorygithub.com/jhillyerd/enmime/v2
modulepackage
2.0.0
Repository: https://github.com/jhillyerd/enmime.git
Documentation: pkg.go.dev

# README

enmime

PkgGoDev Build and Test Go Report Card Coverage Status

enmime is a MIME encoding and decoding library for Go, focused on generating and parsing MIME encoded emails. It is being developed in tandem with the Inbucket email service.

enmime includes a fluent interface builder for generating MIME encoded messages, see the wiki for example Builder Usage.

See our Pkg Docs for examples and API usage information.

Development Status

enmime is production quality, but there are many buggy MIME encoders in the wild, so you may still encounter messages it cannot parse.

See CONTRIBUTING.md for more information.

About

enmime is written in Go.

enmime is open source software released under the MIT License. The latest version can be found at https://github.com/jhillyerd/enmime

# Packages

Package dsn meant to work with Delivery Status Notification (DSN) per rfc3464: https://datatracker.ietf.org/doc/html/rfc3464.

# Functions

AllowCorruptTextPartErrorPolicy recovers partial content from base64.CorruptInputError when content type is text/plain or text/html.
Builder returns an empty MailBuilder struct.
DecodeHeaders returns a limited selection of mime headers for use by user agents Default header list: "Date", "Subject", "Sender", "From", "To", "CC" and "BCC" Additional headers provided will be formatted canonically: h, err := enmime.DecodeHeaders(b, "content-type", "user-agent").
DecodeRFC2047 decodes the given string according to RFC 2047 and returns the decoded UTF-8 equivalent.
DisableCharacterDetection sets the disableCharacterDetection option.
DisableTextConversion sets the disableTextConversion option.
EnvelopeFromPart uses the provided Part tree to build an Envelope, downconverting HTML to plain text if needed, and sorting the attachments, inlines and other parts into their respective slices.
IsBase64CorruptInputError returns true when err is of type base64.CorruptInputError.
MaxStoredPartErrors limits number of part parsing errors, errors beyond the limit are discarded.
MinCharsetDetectRunes sets the minimum length of a MIME part before enmime will attempt to detect its character set.
MultipartWOBoundaryAsSinglePart if set to true will treat a multi-part messages without boundary parameter as single-part.
NewParser creates new parser with given options.
NewPart creates a new Part object.
NewSMTP creates a new SMTPSender, which uses net/smtp.SendMail, and accepts the same authentication parameters.
ParseAddressList returns a mail.Address slice with RFC 2047 encoded names converted to UTF-8.
RawContent if set to true will not try to decode the CTE and return the raw part content.
ReadEnvelope is a wrapper around ReadParts and EnvelopeFromPart.
ReadHeader reads a block of SMTP or MIME headers and returns a textproto.MIMEHeader.
ReadParts reads a MIME document from the provided reader and parses it into tree of Part objects.
SetCustomParseMediaType if provided, will be used to parse media type instead of the default ParseMediaType function.
SetReadPartErrorPolicy sets the given callback function to readPartErrorPolicy.
SkipMalformedParts sets parsing to skip parts that's can't be parsed.
StripMediaTypeInvalidCharacters sets stripMediaTypeInvalidCharacters option.

# Constants

ErrorCharsetConversion name.
ErrorCharsetDeclaration name.
ErrorContentEncoding name.
ErrorMalformedBase64 name.
ErrorMalformedChildPart name.
ErrorMalformedHeader name.
ErrorMissingBoundary name.
ErrorMissingContentType name.
ErrorMissingRecipient name.
ErrorPlainTextFromHTML name.

# Variables

AddressHeaders is the set of SMTP headers that contain email addresses, used by Envelope.AddressList().

# Structs

Envelope is a simplified wrapper for MIME email messages.
Error describes an error encountered while parsing.
MailBuilder facilitates the easy construction of a MIME message.
Parser parses MIME.
Part represents a node in the MIME multipart tree.
SMTPSender is a Sender backed by Go's built-in net/smtp.SendMail function.

# Interfaces

ErrorCollector is an interface for collecting errors and warnings during parsing.
Option to configure parsing.
Sender provides a method for enmime to send an email.

# Type aliases

CustomParseMediaType parses media type.
PartMatcher is a function type that you must implement to search for Parts using the BreadthMatch* functions.
ReadPartErrorPolicy allows to recover the buffer (or not) on an error when reading a Part content.