https://github.com/protonmail/go-mime
https://github.com/protonmail/go-mime
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/protonmail/go-mime
- Owner: ProtonMail
- License: mit
- Created: 2019-05-14T15:22:55.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-22T10:35:04.000Z (over 3 years ago)
- Last Synced: 2025-04-10T20:54:23.193Z (about 1 year ago)
- Language: Go
- Size: 59.6 KB
- Stars: 19
- Watchers: 6
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```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()
```