eml2md
A fast, lightweight command-line tool to convert EML (email) files to Markdown format.
Features
- EML Parsing: Parse standard EML files including headers (From, To, CC, Date, Subject) and body content
- Multiple Formats: Support for
simple(plain text) andhtmloutput formats - Attachment Handling: Embed inline images as base64 data URIs in the output
- Clean Output: Email metadata formatted as Markdown tables for easy reading
Installation
From Source
Requires Rust (2024 edition).
The binary will be available at target/release/eml2md.
Usage
Options
| Option | Description | Required | Default |
|---|---|---|---|
-i, --input |
Input EML file path | Yes | - |
-o, --output |
Output Markdown file path | Yes | - |
-f, --format |
Output format (simple or html) |
No | simple |
Example
# Convert email to markdown
# Use HTML format
Output Format
The generated Markdown includes a metadata table and the email body:
Hello,
This is the email body content...
Development
Prerequisites
- Rust (2024 edition)
- Cargo
Building
# Development build
# Release build
Code Quality
# Run all checks
# Individual checks
Testing
Project Structure
eml2md/
├── src/
│ ├── main.rs # CLI entry point
│ ├── lib.rs # Library exports
│ ├── eml.rs # EML parsing (Email, Header, Body, Attachment)
│ ├── content_type.rs # MIME type parsing
│ └── formatter/
│ ├── mod.rs # Formatter trait and factory
│ └── simple.rs # SimpleFormatter & SimpleHtmlFormatter
├── tests/
│ └── example/ # Example EML files for testing
├── Cargo.toml
└── Makefile
Dependencies
| Crate | Purpose |
|---|---|
| clap | Command-line argument parsing |
| mail-parser | EML/MIME message parsing |
| chrono | Date/time handling |
| base64 | Base64 encoding for attachments |
| anyhow | Error handling |
| thiserror | Custom error types |
License
Apache-2.0