multimime

package module
v0.0.0-...-4070c4a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2022 License: MIT Imports: 6 Imported by: 0

README

multimime

Go library for parsing multipart MIME emails

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombineParts

func CombineParts(parts []Part) (text string, err error)

CombineParts returns the body of each part, concatenated and separated by new lines

func GetInlineText

func GetInlineText(r io.Reader) (text string, err error)

func GetMessageType

func GetMessageType(message *mail.Message) (mediatype string, params map[string]string, err error)

GetMessageType returns the media type and params from a mail.Message

func GetMultipartReader

func GetMultipartReader(r io.Reader) (*multipart.Reader, error)

GetMultipartReader returns a multipart.Reader from an io.Reader

Returns an error if the io.Reader does not contain an email or if it is not a multipart email

func GetPartContent

func GetPartContent(part multipart.Part) (content []byte)

GetPartContent returns the content (body) of a multipart.Part

func GetPartDisposition

func GetPartDisposition(part *multipart.Part) string

GetPartDisposition returns the Content-Disposition media type

If the header is not set, an empty string is returned

func GetPartType

func GetPartType(part *multipart.Part) string

GetPartType returns the media type from a multipart.Part

func IsAttachment

func IsAttachment(part *multipart.Part) bool

IsAttachment returns true if the part disposition starts with attachment

Implements MultipartFindFunc

func IsHtmlPart

func IsHtmlPart(part *multipart.Part) bool

IsHtmlPart returns true for text/html media types

Implements MultipartFindFunc

func IsInlineTextPart

func IsInlineTextPart(part *multipart.Part) bool

IsInlineTextPart returns true for text parts that are not attachments

Implements MultipartFindFunc

func IsPlainTextPart

func IsPlainTextPart(part *multipart.Part) bool

IsPlainTextPart returns true for text/plain media types

Implements MultipartFindFunc

func IsTextPart

func IsTextPart(part *multipart.Part) bool

IsTextPart returns true for text media types

Implements MultipartFindFunc

Types

type MultipartFindFunc

type MultipartFindFunc func(*multipart.Part) bool

MultipartFindFunc is used to filter parts

Returns true if the part should be included, and false if it should be filtered out

type Part

type Part struct {
	multipart.Part
	Content []byte
}

Part is a multipart.Part and its Content

func FindParts

func FindParts(r *multipart.Reader, findFunc MultipartFindFunc) (parts []Part, err error)

FindParts returns a list of Parts for which findFunc returns true

func GetAllParts

func GetAllParts(r io.Reader) ([]Part, error)

GetAllParts returns a list of all Parts

func GetAttachments

func GetAttachments(r io.Reader) ([]Part, error)

GetAttachments returns a list of Parts that are attachments

func GetHtmlParts

func GetHtmlParts(r io.Reader) ([]Part, error)

GetHtmlParts returns a list of Parts that are text/html

func GetParts

func GetParts(r io.Reader, findFunc MultipartFindFunc) ([]Part, error)

GetParts converts an io.Reader to a multipart.Reader and calls FindParts

func GetPlainTextParts

func GetPlainTextParts(r io.Reader) ([]Part, error)

GetPlainTextParts returns a list of Parts that are text/plain

func GetTextParts

func GetTextParts(r io.Reader) ([]Part, error)

GetTextParts returns a list of Parts that are text/*

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL