https://github.com/nathanborror/swift-mime
MIME encoding and decoding library for Swift.
https://github.com/nathanborror/swift-mime
mime swift
Last synced: 12 days ago
JSON representation
MIME encoding and decoding library for Swift.
- Host: GitHub
- URL: https://github.com/nathanborror/swift-mime
- Owner: nathanborror
- License: mit
- Created: 2025-10-16T15:53:53.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2026-04-07T04:12:14.000Z (4 months ago)
- Last Synced: 2026-04-07T05:34:07.991Z (4 months ago)
- Topics: mime, swift
- Language: Swift
- Homepage:
- Size: 229 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MIME
A Swift package for parsing and encoding MIME formatted data (RFC 2045/2046).
## Requirements
- iOS 18.0+ / macOS 15.0+
- Swift 6.2+
## Installation
```swift
dependencies: [
.package(url: "https://github.com/nathanborror/swift-mime.git", branch: "main")
]
```
## Quick Example
```swift
import MIME
let mimeString = """
From: sender@example.com
Content-Type: multipart/mixed; boundary="example"
--example
Content-Type: text/plain
Hello, World!
--example--
"""
let message = try MIMEDecoder().decode(mimeString)
// Access headers and parts
print(message.headers["From"]) // "sender@example.com"
print(message.parts[0].body) // "Hello, World!"
// Encode back to MIME format
let encoded = MIMEEncoder().encode(message)
```
## Documentation
For detailed usage examples, see the test files:
- `MIMETests.swift` - Decoding/encoding multipart and nested messages
- `MIMEHeaderTests.swift` - Working with headers and duplicate headers
- `MIMEAttributeTests.swift` - Parsing header attributes (charset, boundary, etc.)