peridot/vendor/github.com/ProtonMail/go-mime
2024-10-16 13:40:38 +02:00
..
.gitignore Initial commit 2022-07-07 22:13:21 +02:00
BUILD.bazel Upgrade gopengpg 2024-10-16 13:40:38 +02:00
encoding.go Upgrade gopengpg 2024-10-16 13:40:38 +02:00
LICENSE Initial commit 2022-07-07 22:13:21 +02:00
parser.go Upgrade gopengpg 2024-10-16 13:40:38 +02:00
README.md Upgrade gopengpg 2024-10-16 13:40:38 +02:00
utf7Decoder.go Initial commit 2022-07-07 22:13:21 +02:00

Go Mime Wrapper Library

Provides a parser for MIME messages

Download/Install

Run go get -u github.com/ProtonMail/go-mime, or manually git clone the repository into $GOPATH/src/github.com/ProtonMail/go-mime.

Usage

The library can be used to extract the body and attachments from a MIME message

Example:

printAccepter := gomime.NewMIMEPrinter()
bodyCollector := gomime.NewBodyCollector(printAccepter)
attachmentsCollector := gomime.NewAttachmentsCollector(bodyCollector)
mimeVisitor := gomime.NewMimeVisitor(attachmentsCollector)
err := gomime.VisitAll(bytes.NewReader(mmBodyData), h, mimeVisitor)
attachments := attachmentsCollector.GetAttachments(),
attachmentsHeaders :=	attachmentsCollector.GetAttHeaders()
bodyContent, bodyMimeType := bodyCollector.GetBody()