All mailboxes in one program: emails sorted by topic automatically
One program for all of an owner’s mailboxes: it fetches the emails, sorts them by topic, learns from every correction and lets the AI pre-sort, summarise and prepare replies.
- For
- Owner with several businesses and private mailboxes
- Mailboxes
- Freemail with many aliases, business mailboxes
- Core
- Retrieval, sorting by topic, search
- AI
- Classifying, summarising, drafts
Starting point
Anyone running several businesses soon has a dozen mailboxes: business addresses, a private account with many aliases for marketplaces, banks and authorities, old addresses that customers still write to. Going through all mailboxes every morning takes time, and important mail from authorities or banks gets lost among advertising and notifications.
So we built a dedicated application for the owner of our lab. It fetches all mailboxes, assigns every email to a topic and lets the AI help where it pays off. It is deliberately separate from the CRM, because staff work in the CRM, while private mail should be seen only by the owner.
How an email moves through the system
- InputRetrievalall mailboxes, read-only
- AutomaticAliaswhich address was it sent to?
- AutomaticLearned rulesender or domain
- AutomaticRule setaddresses, domains, words
- ResultTopicor “Unclear”
When the owner reclassifies an email, the system remembers the rule
- Read-only retrieval: The application connects to every mailbox via IMAP and downloads new emails from the inbox and sent folder. Nothing is changed on the mail server, not even the “read” flag. The email app on phone and PC keeps working as before.
- Archive: The first retrieval imports up to ten years. Every email is stored as the original file and added to a search index. If the same email arrives via two mailboxes, it appears only once.
- Alias addresses: Many providers deliver emails for alias addresses into the same mailbox. The application reads the headers to see which address an email was sent to. An address can be assigned a fixed topic, for example the address used only for one marketplace.
Sorting by topic
- Business mailboxescustomers, suppliers
- Private mailboxwith many aliases
- Marketplacessales, messages
- Authorities and banksnotices, transactions
First matching rule wins
- Businessper business area
- Salesper marketplace account
- Finance and authoritiesbank, tax, insurance
- Privatefamily, school, travel
Every email gets exactly one topic. The checks run in a fixed order, and the first matching stage decides:
- Alias with a fixed topic: If the email went to an address with an assigned topic, the result is settled.
- Learned rule: If the owner or the AI has already classified an email from this sender or domain with “remember”, that rule applies.
- Spam check: A points system rates features such as hidden text, fake reply subjects or third-party brand names in the sender. The mail provider’s spam flags are added.
- Rule set: First sender addresses and domains, then words in the subject and body. The order of topics determines priority.
- Otherwise “Unclear”: Anything that no rule matches lands in a separate area and is classified by hand or by the AI.
The result is then refined. A sales notification, for example, goes to the subtopic of the marketplace account whose address it was sent to. Every topic belongs to the business or private area. The owner maintains topics, colours and subtopics himself. If he changes the rule set, all emails can be reclassified with one click. Anything he classified himself stays unchanged.
AI as an assistant
- Chat in the program: An assistant at the bottom right searches and reads emails, summarises threads and answers questions such as “What came from the tax office this week?”.
- Classification: The AI assigns emails in the “Unclear” area to a topic. If it is unsure, the email stays there.
- Drafts: The AI writes replies as drafts, in the language of the incoming email. They are sent from the alias the email went to, so the recipient sees the familiar address.
- Daily review: A scheduled task reads the new emails every morning and reports only what matters, according to rules set by the owner. Areas already handled by other programs, such as customer inquiries in the CRM, are left out.
Automatic replies
Sending is protected twice. One switch allows sending from the program at all, a second switch also allows the AI to send. Without both, only drafts are created. On this basis, automatic replies can be set up for individual topics, such as confirmations of receipt, standard information or forwarding to the responsible person. The rules are set per topic; everything else remains a draft.
The engine behind it
- Lean: Python with the standard library and two additional packages, an SQLite database with full-text search, an interface without build tools. Little that can become outdated or break.
- One codebase, two programs: Post is a second mode of the same code as the lab’s CRM. Improvements to retrieval, spam checking or search benefit both.
- AI with a queue: Requests to the AI run through a queue with a separate lane for the chat. After a restart, open tasks are resumed.
- Emergency switch: If the main AI fails, an AI from another provider takes over automatically.
- Tools for the AI: Through an interface based on the MCP standard, the AI works with the mailbox from a normal chat. Every call is logged.
- Backup: daily backup of the database and email files. Since nothing is deleted on the mail server, the original messages also remain there.
Do you have a similar process?
Briefly describe how many mailboxes you have and what takes up most of your time. We will tell you what can be sorted automatically.