Skip to Content

Odoo turned a shared inbox into twelve leads. An IMAP filter fixed it.

Fetchmail IMAP Filter, a free LGPL-3 add-on for Odoo 18, 19 and 20, sets the IMAP folder and search criteria per incoming mail server.
November 25, 2026 by

Video: https://youtu.be/NsFglRAF_2I

Fetchmail IMAP Filter is a free, open source add-on for Odoo 18, 19 and 20. With it, each incoming IMAP mail server fetches the unread mails that match a folder and IMAP search criteria set on that server.

The problem

Odoo's incoming mail server (fetchmail) opens INBOX on every run and asks the mail server for (UNSEEN), every unread mail (addons/mail/models/fetchmail.py, check_unread_messages). With Create a New Record: Lead selected, new conversations that are not routed elsewhere can create CRM leads.

We measured it on an Odoo 19 Community test database with a local test IMAP server and twelve fictional unread mails: three customer inquiries sent to the sales alias, three newsletters, three spam mails and three notifications.

Without the add-on With (UNSEEN TO "sales@muster-tools.example")
IMAP search Odoo sends SEARCH (UNSEEN) SEARCH (UNSEEN TO "sales@muster-tools.example")
Leads after one fetch 12, including "Congratulations, you won CHF 1,000,000" 3, only the inquiries
Unread mails left in the mailbox 0 of 12 9 of 12
Leads after a second fetch still 12 still 3

The unread row is easy to miss: core fetchmail marks every mail it fetches as read, so the people who also read that inbox in their mail client lose their unread markers.

Odoo CRM pipeline with twelve leads after one unfiltered fetch, demo data

What the add-on does

It adds two fields to each IMAP server under Settings / Technical / Email / Incoming Mail Servers (developer mode):

  • IMAP Folder, default INBOX.
  • IMAP Search Criteria, default (UNSEEN).

The defaults reproduce what Odoo did before, so nothing changes until you edit them. On each fetch the add-on runs SELECT <folder> and SEARCH <criteria> instead of the hard-coded pair. In our demo the shared inbox info@ also receives the alias sales@, so (UNSEEN TO "sales@muster-tools.example") keeps only mails whose To header contains the sales address.

The search runs on the mail server and can use keys such as To, From, Subject or a header.

Odoo CRM pipeline with three leads after the filtered fetch, demo data

Validation rules

The criteria must start with UNSEEN. Saving (ALL), (NOT UNSEEN) or (OR UNSEEN SEEN) fails with a validation error, because a broader search can download already read mail again on every run.

Saving the server also rejects:

  • criteria with non-ASCII characters, because the IMAP connection cannot send them in a search;
  • criteria that end with an IMAP literal such as {5}, because the mail server would wait for data that is never sent;
  • a line break in the folder or the criteria, so the value cannot carry a second IMAP command.

A folder name with non-ASCII characters is encoded to IMAP modified UTF-7 automatically, and a name with a space is quoted. If the mail server refuses the SELECT, the error names the folder, for example IMAP SELECT of folder 'Odoo' returned NO.

Facts

Sources

  • Odoo 19 core: addons/mail/models/fetchmail.py.
  • Add-on: fetchmail_imap_filter/models/fetchmail_server.py, README and docs/admin-guide.md.
  • Measurement: local test database and test IMAP server, fictional mails only.
Your AI agent can edit your Odoo. Here is what Odoo should refuse