|
1 | 1 | --- |
2 | | -title: Sending Emails |
| 2 | +title: "Sending Emails (Composer)" |
3 | 3 | weight: 5 |
4 | 4 | --- |
5 | 5 |
|
6 | | -neomd sends every email as `multipart/alternative`: |
| 6 | +## Beautiful Markdown Composer with **Live-Preview** in Neovim |
| 7 | + |
| 8 | +Since you compose every email in Neovim as a `neomd-*.md` buffer, a small markdown plugin setup makes the writing experience much nicer — headings get colored blocks, code fences get borders, bullets get spacing, and callouts (`> [!note]`) render with icons live as you type. |
| 9 | + |
| 10 | +### Workflow of Writing and Composing an Email |
| 11 | +1. **Pre-Composer**: Fill in your emails and subject: |
| 12 | + |
| 13 | + |
| 14 | +2. **Composer**: Write your email in Neovim with Markdown rendering enabled (see configs below): |
| 15 | + |
| 16 | + |
| 17 | +3. **Post-Composer and Pre-Sent View**: Preview, change FROM sender, attach files, etc.: |
| 18 | + |
| 19 | + |
| 20 | +4. **Preview in Browser**: Preview email in Browser - shows emails, Markdown rendered HTML. |
| 21 | + |
| 22 | + |
| 23 | +### Optional Neovim Configuratios |
| 24 | +*Recommended for nice look and live rendering while you compose your emails* |
| 25 | + |
| 26 | +The single plugin that does most of the work is [render-markdown.nvim](https://github.com/MeanderingProgrammer/render-markdown.nvim). Drop this file into your lazy.nvim plugin folder (e.g. `~/.config/nvim/lua/plugins/markdown.lua`): |
| 27 | + |
| 28 | +```lua |
| 29 | +return { |
| 30 | + -- Live inline rendering: headings, code blocks, bullets, callouts |
| 31 | + { |
| 32 | + "MeanderingProgrammer/render-markdown.nvim", |
| 33 | + ft = { "markdown" }, |
| 34 | + dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, |
| 35 | + keys = { |
| 36 | + { "<leader>mr", ":RenderMarkdown toggle<CR>", desc = "Markdown render toggle" }, |
| 37 | + }, |
| 38 | + opts = { |
| 39 | + heading = { |
| 40 | + sign = false, |
| 41 | + position = "inline", |
| 42 | + icons = { "# ", "## ", "### ", "#### ", "##### ", "###### " }, |
| 43 | + width = "block", |
| 44 | + left_pad = 2, |
| 45 | + right_pad = 4, |
| 46 | + }, |
| 47 | + code = { |
| 48 | + sign = false, |
| 49 | + left_pad = 2, |
| 50 | + right_pad = 4, |
| 51 | + border = "thick", |
| 52 | + }, |
| 53 | + bullet = { right_pad = 2 }, |
| 54 | + }, |
| 55 | + }, |
| 56 | + |
| 57 | + -- Optional: bold / italic / link toggles via Alt-key chords in visual mode |
| 58 | + { |
| 59 | + "tadmccorkle/markdown.nvim", |
| 60 | + ft = "markdown", |
| 61 | + opts = { |
| 62 | + on_attach = function(bufnr) |
| 63 | + local toggle = function(key) |
| 64 | + return "<Esc>gv<Cmd>lua require'markdown.inline'" |
| 65 | + .. ".toggle_emphasis_visual'" .. key .. "'<CR>" |
| 66 | + end |
| 67 | + vim.keymap.set("x", "<M-i>", toggle("i"), { buffer = bufnr }) -- italic |
| 68 | + vim.keymap.set("x", "<M-b>", toggle("l"), { buffer = bufnr }) -- bold |
| 69 | + vim.keymap.set("x", "<M-k>", toggle("l"), { buffer = bufnr }) -- link |
| 70 | + end, |
| 71 | + }, |
| 72 | + }, |
| 73 | +} |
| 74 | +``` |
7 | 75 |
|
8 | | -- **`text/plain`** — the raw Markdown you wrote (readable as-is in any client) |
9 | | -- **`text/html`** — rendered by [goldmark](https://github.com/yuin/goldmark) with a clean CSS wrapper |
| 76 | +Toggle rendering on/off with `<leader>mr`. For the full version (with browser preview, wikilinks, custom highlights), see my live config at [markdown.lua](https://github.com/sspaeti/dotfiles/blob/master/nvim/.config/nvim/lua/sspaeti/plugins/markdown.lua). |
10 | 77 |
|
11 | | -This means recipients using Gmail, Apple Mail, Outlook, etc. see properly formatted links, bold, headers, inline code, and code blocks — while you write nothing but Markdown. |
12 | 78 |
|
13 | | -When attachments are present the MIME structure is upgraded automatically: |
14 | | -- **Images** → `multipart/related` with `Content-ID` — displayed inline in the email body |
15 | | -- **Other files** (PDF, zip, …) → `multipart/mixed` — shown as downloadable attachments |
16 | 79 |
|
17 | 80 | ## Multiple From Addresses |
18 | 81 |
|
@@ -248,6 +311,18 @@ Simon |
248 | 311 | ``` |
249 | 312 |
|
250 | 313 |
|
| 314 | +## Format that email is sent |
| 315 | +neomd sends every email as `multipart/alternative`: |
| 316 | + |
| 317 | +- **`text/plain`** — the raw Markdown you wrote (readable as-is in any client) |
| 318 | +- **`text/html`** — rendered by [goldmark](https://github.com/yuin/goldmark) with a clean CSS wrapper |
| 319 | + |
| 320 | +This means recipients using Gmail, Apple Mail, Outlook, etc. see properly formatted links, bold, headers, inline code, and code blocks — while you write nothing but Markdown. |
| 321 | + |
| 322 | +When attachments are present the MIME structure is upgraded automatically: |
| 323 | +- **Images** → `multipart/related` with `Content-ID` — displayed inline in the email body |
| 324 | +- **Other files** (PDF, zip, …) → `multipart/mixed` — shown as downloadable attachments |
| 325 | + |
251 | 326 |
|
252 | 327 | ## Mailto Handler |
253 | 328 |
|
|
0 commit comments