# postino: MIME email over SMTP for D postino is a library for the D programming language that builds MIME emails (plain text, HTML, embedded images, attachments) and sends them over SMTP through libcurl (`std.net.curl`), or saves them as `.eml` files. One class, `Email`, with chainable setters. Version 0.1.8, MIT license. - Full reference: https://trikko.github.io/postino/llms-full.txt - Rules for agents: https://trikko.github.io/postino/AGENTS.md (as a skill: https://trikko.github.io/postino/SKILL.md) - API documentation: https://trikko.github.io/postino/ - Source: https://github.com/trikko/postino ## Core Concepts - **Email**: `new Email()`, then chainable setters; every setter returns the same object. - **Addresses**: `setFrom(address, name?)`, `addTo`, `addCc`, `addBcc`, `setReplyTo`. Checked when added: an invalid address throws `PostinoException` at once. Bcc recipients receive the email and are never in the headers. Internationalized domains become punycode. - **Content**: `setSubject`, `setPlainTextBody`, `setHtmlBody` (UTF-8, encoded for you: RFC 2047 headers, quoted-printable bodies). - **Files**: `attachFile(path, mimeType?, name?)` or `addAttachment(const(ubyte)[] data, mimeType, name?)`; `embedFile(path, cid, mimeType?)` or `addEmbeddedFile(const(ubyte)[] data, cid, mimeType)`, shown in the HTML with `src="cid:..."`. Data is copied; files are read when sending. `addAttachment(path)`/`addEmbeddedFile(path, cid)` are deprecated aliases of the file methods. - **Headers**: `addHeader(name, value)` for `List-Unsubscribe`, `In-Reply-To`, `References`, `X-...`; the headers postino writes itself are refused. - **Many emails**: `clone()` copies a message; `clearTo`, `clearCc`, `clearBcc`, `clearHeaders`, `clearAttachments`, `clearEmbeddedFiles`. The same `SMTP` object passed to every `send` reuses the connection. - **Sending**: `send(url, username?, password?, smtp?)`, or `send(url, username, OAuth2(accessToken), smtp?)` for XOAUTH2. `smtps://host:465` is implicit TLS; `smtp://host:587` with credentials requires STARTTLS; `smtp://host:25` without credentials is plain. Credentials go to `send`, never in the URL (refused). Errors are exceptions. - **Saving**: `save(path)` writes the same message as an `.eml` file, without sending it. The message is built once: `save` after `send` writes exactly what was sent; `renew()` forces a new Date, Message-ID and boundaries. ## Installation & Basic Usage `dub add postino`. dmd or ldc2; libcurl at run time. ```d import postino; new Email() .setFrom("sender@example.com", "Sender") .addTo("alice@example.com", "Alice") .addBcc("archive@example.com") .setSubject("Hello") .setPlainTextBody("Hello Alice") .setHtmlBody("

Hello Alice

") .attachFile("/tmp/report.pdf") .send("smtp://smtp.example.com:587", "user", "password"); ``` ## Limits Blocking. No DKIM, no templates, no SMTPUTF8, no receiving mail; OAuth2 tokens are sent, not obtained. `smtps://` on port 587 does not work: 587 is `smtp://` with STARTTLS.