Swiftpack.co - miximka/MimeParser as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by miximka.
miximka/MimeParser 0.2.5
Mime parsing in Swift | Relevant RFCs: RFC 822, RFC 2045, RFC 2046
⭐️ 18
🕓 33 weeks ago
.package(url: "https://github.com/miximka/MimeParser.git", from: "0.2.5")

Build Status


MimeParser is a simple MIME (Multipurpose Internet Mail Extensions) parsing library written in Swift (to learn more about mimes refer to RFC 822, RFC 2045, RFC 2046)



CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate MimeParser into your Xcode project using CocoaPods, specify it in your Podfile:

project '<Your Project Name>.xcodeproj'
platform :osx, '10.12'

target 'Test' do
  pod 'MimeParser', '~> 0.1'

Then, run the following command:

$ pod install


Import MimeParser before using it:

import MimeParser

Create parser object:

let parser = MimeParser()

Let this be a simplest mime to be parsed:

let str = """
	Content-Type: text/plain

You are ready to parse the mime:

let mime = try parser.parse(str)

Returned mime object is a root of the mime tree and provides access to its header fields and content:

public enum MimeContent {
    case body(MimeBody)
    case mixed([Mime])
    case alternative([Mime])

public struct MimeHeader {
    public let contentTransferEncoding: ContentTransferEncoding?
    public let contentType: ContentType?
    public let contentDisposition: ContentDisposition?
    public let other: [RFC822HeaderField]

if let contentTypeString = mime.header.contentType?.raw {
	// "text/plain"

if case .body(let body) = mime.content {
	// "Test"

Decoded mime's content is simply to retrieve:

let content = try mime.decodedContentData()
// "Test"


MimeParser is available under the MIT license. See the LICENSE file for more info.


MimeParser is still very simple and incomplete, so pull requests welcome!


Stars: 18
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

33 weeks ago

Fixed #11

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics