Email tagging

Open
#598 2 comments 2 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript
Domain
full-stack

Research direction

The reporter’s fork contains a working implementation based on v3.9.0, but the issue does not name current files or tests to start from. First compare the fork’s tag implementation with the current main branch and identify the storage and message-list entry points. Agree on the database-only storage approach and scope before estimating a contribution; done means users can manage tags, apply several to messages, and filter the unified inbox by any or all tags.

Written by the indexing model from the issue text.

Description

enhancement

Is your feature request related to a problem? Please describe.
I use several accounts and receive a large number of emails per day. The existing tools cover part of my needs: inbox rules and categories sort mail automatically, and the GTD rail lets me label a thread with one of five predefined states. What I can't do is attach my own labels to an email, several at once, and filter on them later.

Folders don't help either: an email lives in a single folder, so cross-cutting criteria (e.g. "urgent" and "important", or "client X" and "to invoice") can't be combined.

Describe the solution you'd like
Free-form tags:

  • Users create and name their own tags (with an optional color).
  • An email can carry several tags at once, without leaving its current folder.
  • The message list can be filtered by one or several tags (AND / OR), including across accounts in the unified inbox.
  • Tags can be added or removed from the context menu, the toolbar, and keyboard shortcuts, and could later be targeted by inbox rules.

A concrete use case: tagging mail with the two axes of an Eisenhower matrix (important / urgent) and filtering on each axis independently, or on both at once. The feature isn't tied to that method; the tag names are entirely up to the user.

Describe alternatives you've considered

  • Folders: one email per folder, so no combination of criteria.
  • GTD rail: fixed set of states, not user-defined, and not meant for cross-cutting labels. (It's a great fit for its own workflow, this would complement it rather than replace it.)
  • Inbox rules / categories: automatic and single-purpose, can't be applied by hand on a per-email basis.

Additional context
I already have this working in a fork: https://github.com/Phenixis/mailflow/tree/feat/tags-core (based on v3.9.0, not yet rebased on current main). I'm happy to open a PR and to adapt the approach to your preferences, in particular on storage. I've read the CLA and agree to it.

Why I built it, and what happens to the fork
I developed this mainly as the foundation for an auto-tagging plugin of my own: the plugin assigns the user's tags to incoming mail with an external classifier, which needs tags to exist as a first-class, user-defined thing in MailFlow. I will keep using this feature in my fork whether or not it is merged here. I'd rather upstream it than carry the divergence (every release would mean rebasing it), so I'm offering it, but there is no pressure: if it doesn't fit the direction of the project, say so and I'll keep it on my side.

What the fork does today

  • Tags are created, renamed, recolored, disabled and deleted from Settings. An email can carry several; they show as small pills in the list rows and in the reading-pane header.
  • Tags can be set by hand from the reading-pane header, the message context menu (on every selected row when the click is on a selection), a Tags button in the bulk-selection toolbar (a bottom sheet on phones, with a toast and a "n of m" count per tag), and a keyboard picker (l, then 1-9).
  • The list can be filtered by one or several tags with an any/all switch; it works in the unified inbox.
  • Not done: inbox rules that target tags, and tagging a whole conversation (in conversation view a tag goes on the row that is shown).

Storage: database only, and why
Tags live in two tables (tag_definitions, message_tags) and nothing is written to the IMAP server. I chose this because it behaves the same on every account regardless of the provider's support for custom IMAP keywords, makes no extra writes to the mailbox, and is easy to reverse. The trade-offs: tags exist only in MailFlow (not in other mail clients), and they follow the message row (so a message moved by MailFlow, e.g. archive or rules, keeps its tags; I haven't checked a message moved by another client). Mirroring tags to IMAP keywords as an opt-in per account could be added later where the server supports it; I'd like to hear whether you'd want that.

Scope of the branch
The branch currently also contains some plugin-API groundwork for the auto-tagging plugin above (apply/remove a tag from a plugin, a restricted outbound-HTTP capability declared in a plugin manifest, secret encryption). That is not part of this proposal, and I would remove it from any PR so the change stays small and focused; I'm glad to open a separate issue for it if you're interested.

All UI strings are in the locale files for the 11 languages, but I wrote the translations with AI assistance and they haven't been reviewed by native speakers, so please treat them as a starting point. One frontend test (InboxReplyDraftObserver) already fails on an untouched v3.9.0 in my environment; everything else passes, and the new tag code has its own tests, including SQL tests on PostgreSQL.

Dominant language
JavaScript
Stars
518
Forks
50
Avg merge
4d 45m
Merged PRs (30d)
43

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from maathimself/mailflow

All issues in maathimself/mailflow

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.