# daaki-message
An RFC 5322 email message parser and builder.
## Highlights
- **Parse and build** — turn raw bytes into structured data, or structured data into raw bytes.
- **Full MIME support** — multipart messages, attachments, Content-Transfer-Encoding, boundary handling.
- **Encoded words** — RFC 2047 decoding and encoding for non-ASCII headers.
- **Internationalized headers** — RFC 6532 UTF-8 support.
- **Zero unsafe code** — enforced by `#![deny(unsafe_code)]` crate-wide.
- **No runtime dependency** — works with any async runtime or without one.
## Quick Start
```toml
[dependencies]
daaki-message = "0.1"
```
### Parsing
Parse a raw email into its structured parts:
```rust
use daaki_message::parse_email;
let raw = b"From: alice@example.com\r\n\
To: bob@example.com\r\n\
Subject: Hi\r\n\
\r\n\
Hello!";
let email = parse_email(raw).unwrap();
assert_eq!(email.subject.as_deref(), Some("Hi"));
assert_eq!(email.text_body.as_deref(), Some("Hello!"));
```
### Building
Construct a well-formed RFC 5322 message from typed inputs:
```rust
use daaki_message::{build_message, OutgoingEmail, Address};
let email = OutgoingEmail {
from: Address { name: Some("Alice".into()), email: "alice@example.com".into() },
to: vec![Address { name: None, email: "bob@example.com".into() }],
subject: Some("Hello from daaki".into()),
text_body: Some("Plain text body".into()),
html_body: None,
..Default::default()
};
let built = build_message(&email).unwrap();
// built.rfc5322_message — the raw bytes, ready to send
// built.envelope_recipients — the addresses for the SMTP envelope
```
## Standards
| **RFC 5322** | Internet Message Format — headers, date-time, address parsing |
| **RFC 2045–2047** | MIME — body format, media types, encoded words |
| **RFC 2183** | Content-Disposition — attachment handling |
| **RFC 2231** | MIME parameter encoding — charset and continuation |
| **RFC 2392** | Content-ID |
| **RFC 6532** | Internationalized email headers |
## License
The contents of this package are licensed under the terms of the MIT license.