peridot/vendor/github.com/ProtonMail/go-mime/README.md

26 lines
793 B
Markdown
Raw Normal View History

2022-07-07 20:11:50 +00:00
# Go Mime Wrapper Library
2024-10-16 11:40:38 +00:00
Provides a parser for MIME messages
2022-07-07 20:11:50 +00:00
## 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`.
2024-10-16 11:40:38 +00:00
## Usage
The library can be used to extract the body and attachments from a MIME message
Example:
```go
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()
```