Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Mail

Greed reads, searches and writes your mail. greed mail opens it in a session of its own, on a full page: your inbox, newest first, with the search box over it.

Nothing of it runs until you open it, and it doesn’t start with Greed unless you ask it to (Sessions says how). Searching everything at once just leaves mail out until there’s a mail.toml.

The mail list, searched for deploy, a thread read, turned into a todo due Thursday, then the agent asked which mail needs an answer this week, naming three messages

What you type narrows the list as you type, in the query language every search in Greed speaks:

in:inbox is:unread                 unread in the inbox
from:anna invoice date:2w..        from Anna, about an invoice, the last two weeks
in:work -is:mine                   in the Work folder or label, not sent by you
account:work is:flagged            flagged, in the work account
subject:"quarterly report" is:attachment
file:invoice type:pdf from:kia     a PDF attached called something with invoice
type:image date:1w..               pictures sent this last week

file: searches the names of what’s attached (a plain word does too), and type: their kind: the extension (pdf, docx, jpg), or image, audio and video for any of those.

Setting it up

Mail needs two things: greed-mail, the program that syncs it, and a mail.toml saying which accounts to sync.

greed-mail comes with Greed: Greed’s packages put it beside greed (the Nix package and the static Linux build too), and Greed finds it there (or on your PATH). If yours is somewhere else, say where with :set mail-program /path/to/greed-mail. On another machine you reach with greed ssh, the greed put there brings it along, so greed mail works there too. Greed and greed-mail check they speak the same way when they meet; one older or newer than the other says so over the list, and which to update, rather than misreading the other.

mail.toml goes in Greed’s config folder: ~/.config/greed/mail.toml, or under $XDG_CONFIG_HOME when that’s set. One account looks like this:

[[account]]
name = "private"
address = "anna@example.com"
imap = { host = "imap.example.com" }
smtp = { host = "smtp.example.com" }
password = ["rbw", "get", "mail"]

password is a command that prints the password, here from Bitwarden; ["pass", "show", "mail"] or ["security", "find-generic-password", "-w", "-s", "mail"] work as well. It runs when a connection needs the password, and the password is never written down. Each setting is explained under mail.toml below; Gmail and Proton have their own ways, shown there too.

If the command waits, say for you to unlock your password manager, the mail list says so over your mail (“waiting for rbw to give the password”) and syncing picks up once it’s given. A sync that fails says why there too, until the next one goes through.

greed-mail check logs in to each account and says what its server can do, which is a quick way to see that mail.toml is right. Then:

greed mail

The first sync brings the newest mail first, and the list fills in as it goes; a message you open has its text fetched ahead of the rest. A big mailbox takes a while the first time (on Proton through Bridge, each message’s text comes from Proton when first asked for). While it syncs, a line over the list says how much of each account is in, and while it indexes, a bar says how far it got. After that, new mail shows within seconds.

The mail session and the quick look

The mail session (mail.service; greed mail from a shell, :mail-session from inside Greed) is the mail client: it has the full page, and it’s the one that syncs. It starts whenever another session needs it, so you never start it yourself, and with Greed too once there’s a mail.toml and services-at-start names mail. Detach from it as from any session; it goes on syncing.

In any other session, :mail opens a quick look: the same mail, in a floating view of the tab over what you’re working on. alt-f hides it and shows it again like the tab’s other floats, :mail brings it back, and q closes it. Threads open in it, and q goes back to the list. It works as the page does, and what you mark, archive, delete, write or answer there, the mail session does for it, starting first if it isn’t running.

After an upgrade, the mail session indexes your mail again the first time it starts (a minute or two for a hundred thousand messages); the list shows how far it got, and fills in as it goes.

Several accounts

Add an [[account]] for each, with a name of your choosing:

[[account]]
name = "private"
address = "anna@example.com"
imap = { host = "imap.example.com" }
smtp = { host = "smtp.example.com" }
password = ["rbw", "get", "private-mail"]

[[account]]
name = "work"
address = "anna.berg@company.example"
imap = { host = "mail.company.example" }
smtp = { host = "mail.company.example", tls = "starttls" }
password = ["rbw", "get", "work-mail"]

[[account]]
name = "gmail"
address = "anna.berg@gmail.com"
provider = "gmail"
password = ["rbw", "get", "gmail-app-password"]

They all sync into one place, so one list shows them all: in:inbox is every account’s inbox together, and a search finds mail in any of them. account: narrows a search to one, by its name:

account:work in:inbox              the work inbox
in:inbox -account:work             every inbox but work's
account:private from:anna          Anna's mail to your private address

For a tab for each, put them in your saved searches:

require("@mail").searches = {
	{ name = "All", query = "in:inbox" },
	{ name = "Private", query = "account:private in:inbox" },
	{ name = "Work", query = "account:work in:inbox" },
	{ name = "Gmail", query = "account:gmail in:inbox" },
}

You don’t need tags to keep accounts apart: account: does that, for mail old and new. Tags are for sorting within your mail, and they live on each account’s server, so a tag set on work mail stays with the work account.

What you write goes through the account it’s from. A reply is from the address the mail was sent to, so a reply to work mail goes from work. New mail (c) starts from the address from names in mail.toml, or your first account’s (see Identities); change the From: line to any other address of yours, and it goes through that account. Changes, like archiving or deleting, happen in the account the message is in.

Rules see every account; add account: to a rule’s query for one alone:

require("@mail").rules = {
	{ query = "account:work from:jira@company.example", tag = "jira", archive = true },
}

The list

In the list, enter reads the thread under the cursor in its place, / searches again and $ syncs now; q in a thread goes back to the list. ] m and [ m go to the next and previous row, and in a thread to the next and previous message. Reading a thread marks it read.

A dot marks unread mail, ⚑ flagged mail and 📎 mail with something attached; a message’s folders, labels and tags follow its subject (#work).

Over the list are your saved searches, each with how many unread messages it finds, counted again as mail comes in. They go as tabs do: tab and shift-tab to the next and the one before, alt-1 to alt-9 to one, and g s picks any of them by name, however many you have; pressing one goes to it too. Set your own in your config (~/.config/greed/init.luau):

require("@mail").searches = {
	{ name = "Inbox", query = "in:inbox" },
	{ name = "Work", query = "in:work is:unread" },
	{ name = "Recent", query = "date:2w.. -is:mine" },
	{ name = "Receipts", query = "(receipt OR invoice) is:attachment" },
}

A thread shows once, as its newest message the search found, with how many it found after the subject ((3)). A change to a row changes those messages and no others of the thread, so archiving a thread found in the inbox leaves your replies in Sent. :set mail-threads false lists every message on its own.

These work on the message under the cursor, or in a thread on all of it:

KeyDoes
umarks it read, or unread when it’s read
sflags it, or takes the flag off
tasks for a tag and puts it on, or takes it off if it’s on
Tmakes a todo of it in your inbox note (see below)
bopens it in a web browser, loading nothing from anywhere
emoves it to the archive
d, #moves it to the trash; in the trash, asks, then deletes
rreplies to who sent it (in a thread, its last message)
areplies to everyone it went to
cwrites new mail
zundoes the last change, or takes back mail just sent

space . lists the same actions for the mail under the cursor, as it does for anything else in Greed, and in mail being written offers to send or discard it.

A change shows at once and goes to the server within seconds. If the server refuses it (a folder that went, say), it’s taken back and Greed says why. z undoes the last one, even once the server has it: something archived goes back where it was, a mark comes off again. Deleting from the trash is for good, so it asks first (y deletes).

Reading

A thread opens on what’s new: messages you’ve read before show as a line each (who, when, how it starts) and open when you press them, and a quote of four lines or more folds into one line saying how many, with the “Anna wrote:” line over it; pressing it shows them. o shows all of the thread at once, and folds it again.

Mail sent as HTML reads laid out in Greed: headings, bold and italics, lists, tables of data (a receipt’s lines) in columns, and tables only there for layout as plain text. What the sender hid stays hidden, and images show as their descriptions: nothing is fetched from anywhere, so no tracking pixel tells the sender you read it. Links show as links; tab goes from one to the next and enter opens it.

h reads the thread as its plain text instead (and back). b, in a thread or the list, opens the message in your web browser as it was sent, with everything that would load from elsewhere blocked: scripts, remote images, fonts and styles.

What’s attached is listed under a message’s header, a line each, with an icon for its kind, its size and how it opens:

📎 2 attached
  📄 Invoice 41.pdf  240.9 kB · opens in Greed
  📄 Contract.docx  31.2 kB · opens with libreoffice

enter on one opens it as any file of its kind opens in Greed: a PDF or a picture in Greed itself, an office document or a video with the program your system (or core.file.open_with, see Other files) opens it with. A program (⚠) never opens, only saves. S saves one where you say (~/Downloads to start; the one under the cursor, or the thread’s only one). The mail session fetches it from the server the first time, whole, and keeps it beside your mail for next time; what’s attached to the last two weeks’ mail and to flagged mail (up to 10 MB a message) it fetches ahead as it syncs, so that opens at once, and without a connection. A file that’s already where you save is never written over. space . on one offers the rest: open, open-outside, save, save-all (everything attached to the thread, in a folder you say) and copy-path; saving offers the folder you saved in last.

Invites

A calendar invite reads as a card over the message: what it is, when in your time zone, where, and who sent it.

┌ Invite ──────────────────────────┐
│ Garden plans                     │
│ Friday 24 Oct 10:00 to 11:00     │
│ The shed                         │
│ From: Bob                        │
│  Accept   Maybe   Decline        │
└──────────────────────────────────┘

enter on Accept, Maybe or Decline sends your answer to whoever sent the invite, the way calendars expect it, so it shows in theirs. It goes from the address the invite was sent to, like any mail, with a copy in Sent. A cancelled invite says so, and an answer to one of yours says who accepted or declined.

Writing

A reply opens with its header lines, the cursor on the line where your text goes and the message you answer quoted under it:

From: anna@example.com
To: Bob Lind <bob@example.com>
Cc:
Subject: Re: Invoice 41

Paid this morning.

On 2026-10-19 08:00, Bob Lind wrote:
> Please pay by Friday.

Edit it as any text, the header lines too (add Bcc: for blind copies, addresses apart by commas). On To:, Cc: and Bcc: addresses complete as you type, from the people you’ve had mail with, those you write to most first; on From:, from your own addresses. :mail-attach FILE attaches a file, on an Attach: line you can edit too (paths apart by commas, 25 MB in all at most).

What you write is Markdown: **bold**, *italic*, [a link](https://…), lists and code. It goes as what you wrote, which reads as it is, and the HTML it makes beside it, so mail programs that show HTML show it set out. Your lines stay as you broke them, a reply’s quoted lines are a quote, and the signature goes as it is. :set mail-markdown false sends plain text alone.

ctrl-enter (or alt-enter, in a terminal that can’t tell ctrl-enter from enter) sends it, while typing too, and so does :mail-send; then it goes back to the list. It waits ten seconds, in which z takes it back and opens it again, then goes, and Greed says when it’s sent. A copy goes in your Sent folder (Gmail and Bridge file it themselves), and the message you answered is marked answered. Mail the server won’t take stays out, and Greed says why.

What you write is kept as a draft a moment after you stop typing, and at once with :w, so it outlasts closing it with :mail-close and the mail session ending. :mail-drafts lists your drafts, newest first: enter goes on writing one, and alt-. on one offers to discard it. Drafts are kept on this machine, beside the store, and go once sent.

While writing:

Keys or commandDoes
ctrl-enter, alt-entersends it
:wkeeps it as a draft now
:mail-closecloses it, kept as a draft
:mail-attach FILEattaches a file
:mail-frompicks which of your addresses it’s from (see Identities)
:mail-draftslists your drafts to go on with one
space .offers to send it, pick who it’s from, or discard it

Sending from space . asks y first; the keys and :mail-send don’t.

Tags

in:work (or tag:work) finds a message’s folders, labels and tags. Proton’s labels and Gmail’s come along as they are. t puts a tag on, or takes it off, on the server, where your other mail apps see it too:

  • On Gmail it’s a Gmail label. Taking one off leaves the message where it is.
  • On Proton it’s a Proton label, one you’ve made in Proton already. It goes on as a copy of the message in the label’s folder, and comes off by deleting it from there, which on Proton takes only the label off. It’s off until the account in mail.toml says labels = true: try it on a message you can lose first.
  • On other servers (Dovecot, Fastmail) it’s an IMAP keyword.

Mail and Hoard

Mail and Hoard, your notes and todos, meet in todos. T on a message (or in a thread) asks for a todo about it, starting as who sent it and what it’s about, and adds it to your inbox note, the one Hoard’s home page opens under Inbox. Say when it’s due in words, as anywhere in Hoard: Bob Lind: Invoice 41 friday, or ... friday remind:09:00 to be reminded. It ends in a link back to the message:

- [ ] Bob Lind: Invoice 41 [mail](mail:41@example.com) due:2026-10-23

From there it’s a todo like any other: it’s on the home page and the agenda when it’s due, its reminder goes off in Greed and on your desktop, and you can move it to any note. Opening the link, as any link in a note opens, reads the thread again at that message, unfolded, in the mail session or as a quick look anywhere else. The link names the one message by its Message-ID, so it keeps working after the mail is archived or moved, and the todo reads well without it too, on your phone say. A [mail](mail:ID) link works in any note, so a meeting’s notes can link the thread they’re about.

Rules

Rules act on new mail as it comes in: a query, and what to do with what it finds. They’re Luau tables in your config (~/.config/greed/init.luau, which runs again when you save it), and the query is the one the search box takes:

require("@mail").rules = {
	{ query = "from:github.com", tag = "github", archive = true },
	{ query = "from:boss@example.com", flag = true },
	{ query = "subject:newsletter", read = true },
}

A rule can mark what it finds read, flag it, put a tag on it, and archive or trash it, in that order. Each rule looks at the new mail on its own, so one that archives doesn’t stop the next from tagging. Rules run in the mail session, on mail that arrives once a mailbox is all synced: what the first sync brings is left as it is.

To see what a rule does before it does it, :mail-rule-try picks one and shows what it finds in the mail you have, changing nothing. :mail-rule-run runs it over all of that, once you’ve said y to how many it finds: for a new rule over mail you already have.

A rule with all = true keeps on over all the mail it finds, not only new mail: after the mail session syncs, at most once an hour. That keeps mail an age, as a retention rule:

require("@mail").rules = {
	-- A list's mail out of the inbox after a month, a shop's to the trash after a week.
	{ query = "in:inbox list:news.example.com date:..30d", archive = true, all = true },
	{ query = "in:inbox from:shop.example date:..1w", trash = true, all = true },
}

One that would change more than a hundred messages at once doesn’t: it says so, and :mail-rule-run does it once you’ve looked, so a query that finds more than you meant can’t move your mail unseen. Rules never delete for good: trashing what’s in the trash is left to you.

Mail and agents

Talk to an agent about your mail as about anything else in Greed. With each message it’s told what you’re in, like “the mail list, searching in:inbox, 198 shown” or “a mail thread of 3 messages”, so you can ask about what’s in front of you:

what language is this in, and what does it say?
is this a real invoice, or phishing?
which of these need an answer from me this week?

For mail that isn’t on screen it has the mail tools, a group it switches on when it needs them (see Agents):

ToolDoes
mail_searchsearches every account with the query the list takes
mail_readreads a thread; it stays unread
mail_showopens a thread for you, as if you’d pressed it
mail_actmarks, flags, tags, archives or trashes mail, asking you first

So you can ask for things like:

find the mail from my bank about the new card this year
summarise what's unread in work since monday
archive the newsletters in my inbox older than a month

The tools reach your mail through the mail session, from any session you ask in, starting it if it isn’t running.

What an agent can and can’t do:

  • What it reads of mail, through the tools, read or focus, is marked as from outside, to read as data: a mail saying “ignore your instructions” is something it read, never something you asked for.
  • Changing mail asks you first, as you’ve set agents to (see Permissions); z in the mail undoes it. Nothing an agent does deletes mail for good: trashing what’s in the trash is left to you.
  • It can write in mail you’re writing, as in any buffer. Sending, with :mail-send or space ., asks you every time, whatever you’ve allowed it.
  • Luau it runs with eval reads what the editor has open, mail too, and what it returns isn’t marked; :set agent-eval ask shows you each run first. An agent you let run shell commands can read the store in ~/.local/share/greed/mail like any file of yours.

Greed sends none of your mail to a model by itself: nothing sorts, summarises or answers it unless you ask an agent to. To have one help with a reply, press r, ask it to write the reply in the mail you’re writing, then read it and send it yourself.

What’s there and what isn’t

There now:

  • IMAP and SMTP accounts, any number, with Gmail (an app password) and Proton (through Bridge) set up for their ways.
  • A local copy of everything, searched as you type, offline too, by sender, subject, text, date, folder or label, account, list, and what’s attached by name and kind.
  • Threads, HTML laid out in Greed with nothing loaded from anywhere, and attachments opened in Greed or the program for them.
  • Writing in Markdown, replies quoting what they answer, address completion, attachments, identities with signatures, a default From, drafts that outlast closing, and ten seconds to take mail back.
  • Read, flag, tag, archive and trash, undoable and sent to the server; rules for new mail and for mail of an age; saved searches as tabs.
  • Answering calendar invites, and todos in Hoard linking back to mail.

Not yet:

  • Forwarding mail, and moving it to a folder of your choosing (on Gmail and Proton, a tag does that).
  • Drafts on the server: they’re kept on this machine only, so your other mail apps don’t see them.
  • Signing in with OAuth, so accounts that only allow that (Microsoft 365, Gmail without app passwords) can’t be added.
  • PGP and S/MIME, for encrypting and signing.
  • An alert when new mail comes, beyond the counts over the list.
  • A calendar: invites are answered, not kept.
  • Contacts from an address book: completion knows the people you’ve had mail with.
  • Replying from the address you got a Bcc’d or forwarded mail at, when it isn’t on the mail’s To or Cc lines: change the From: line.
  • Windows.

mail.toml

Each [[account]] has:

SettingWhat it is
namewhat you call it: account:NAME searches it
addressits address; new mail is from it, and you log in as it
passworda command that prints the password
imapwhere its mail is: { host, port, tls }
smtpwhere its mail is sent, with the same login
userwho logs in, when it isn’t the address
aliasesthe other addresses it gets mail at and sends from
providergmail or proton-bridge, for their ways; leave it out for any other
labelstrue lets t set Proton labels (see Tags); off without it

tls is implicit (the default: ports 993 for IMAP, 465 for SMTP), starttls (ports 143 and 587), or none for a server on this machine only. port is needed only when it isn’t one of those.

aliases are you too: mail from them counts as yours (is:mine), a reply or an invite’s answer goes from the alias it was sent to, From: may name any of them, and they’re never offered as people to write to.

Identities

How mail goes out from an address: the name on its From line, a signature, where replies go and a copy to yourself. Set them on the account, and for an alias that’s different, in an [[account.identity]] under it; what an identity leaves out, the account’s settings give:

[[account]]
name = "proton"
address = "anna@proton.me"
aliases = ["support@spool.example"]
display_name = "Anna Berg"
signature = "Anna"
bcc = "anna@proton.me"

[[account.identity]]
address = "support@spool.example"
display_name = "Hyperspool Support"
signature_file = "~/.config/greed/support.sig"
reply_to = "help@spool.example"
SettingWhat it does
display_namethe name on the From line: Anna Berg <anna@proton.me>
signaturethe signature, written here
signature_filethe signature, from a file (in place of signature)
reply_towhere replies go, on a Reply-To: line you can change
bccwho gets a copy, on the Bcc: line, like yourself

New mail and replies are written with the identity of the address they’re from: the From line with its name, a Reply-To: and Bcc: filled in, and the signature under where you write (above the quote in a reply), after a -- line as mail programs expect. All of it is there in the text to change before sending. An identity’s address must be the account’s or one of its aliases.

New mail is from your first account’s address unless from, at the top of mail.toml, names another of yours:

from = "support@spool.example"

[[account]]
…

A reply is from the address the mail was sent to, among your own. To send from another, :mail-from (or space . in the mail, then from) picks one of your addresses by name: the From line changes, and with it the signature, Reply-To and Bcc, where they’re still as the last identity put them; one you’ve changed stays as you left it.

Gmail

[[account]]
name = "gmail"
address = "anna.berg@gmail.com"
provider = "gmail"
password = ["rbw", "get", "gmail-app-password"]

Gmail needs no imap or smtp. Its password here is an app password (made under your Google account’s security settings, with two-step verification on), not the one you sign in with. Gmail’s labels are places like folders: in:receipts finds what’s labelled Receipts.

Proton

Proton’s mail comes through Proton Mail Bridge, which runs on your machine (or another you reach) and gives each account an IMAP and an SMTP port and a password of its own:

[[account]]
name = "proton"
address = "anna@proton.me"
aliases = ["anna@pm.me", "hello@annaberg.example"]
provider = "proton-bridge"
imap = { host = "127.0.0.1", port = 1143, tls = "starttls" }
smtp = { host = "127.0.0.1", port = 1025, tls = "starttls" }
password = ["pass", "show", "mail/bridge"]

The ports, the password and whether it’s starttls are the ones Bridge shows for the account. List every address Proton lets you send from in aliases. Proton’s labels are places like folders, and folders under Proton’s Folders/ show without it.

How syncing works

greed-mail syncs your accounts into a store on this machine (in Greed’s data folder, ~/.local/share/greed/mail) and keeps an index of it that Greed searches, so searching never waits on a server. Changes you make are made in the store at once and sent to the server in the next round, within seconds.

Once everything is in, new mail shows within seconds: greed-mail waits on each account’s inbox for the server to say something arrived (IMAP IDLE), and checks every two minutes on a server that can’t. When an account can’t be reached it tries again a little later each time, up to every five minutes. greed-mail sync syncs once, on its own, if you want to see it work. Until an account is all in, the mail list shows a bar for it over your mail, how many messages are here of how many the server has. Headers come first, every mailbox’s, so all your mail shows up in the list and searches early on. Bodies follow. One you open doesn’t wait for any of that: it’s fetched right away on a connection of its own, same for an attachment you open.

Sometimes a server shows a big mailbox nearly empty for a while. Proton Bridge does it when its disk fills up (its temporary files go to /tmp), or while it rebuilds its cache. So when fewer than half of the messages you have here are on the server, greed-mail leaves the mailbox alone and the mail list says so, until the rest are back. If they really did go, greed-mail --start-over sync lets them go here too.