stalwartlabs / mail-server

Secure & Modern All-in-One Mail Server (IMAP, JMAP, POP3, SMTP)
https://stalw.art
4.8k stars 194 forks source link

[enhancement]: Add option to include arbitrary headers in search indexes #501

Open aldem opened 4 months ago

aldem commented 4 months ago

Which feature or improvement would you like to request?

It would be nice to have an option to include in search indexes arbitrary headers, not only those specified in the RFCs.

Ideally it should be possible to include headers by pattern or even regex, thus in configuration like this:

[[index.headers]]
include = ["X-GitHub-Reason", "X-GitHub-Sender"]

[[index.headers]]
exclude = ["X-GitHub-*"]

will add only headers listed in include and exclude anything else that starts with X-GitHub- (i.e. first match wins).

Standard headers could we always implicitly included to keep backward compatibility.

Is your feature request related to a problem?

The main problem is that the To header or even the From header could not be trusted.

Senders (especially mailing lists) may use generic name in To (which may have nothing to do with the subscription address or even the list itself, like generic "List Users"), while From also may have some completely unrelated or incorrect data (not necessary due to malicious intent).

Some mailers include headers like Envelope-To and Envelope-From (or they could be generated by crafting special configuration or filtering) and those headers are very useful especially for cases when one has many aliases which are landing on the same mailbox (I have more than 100, for instance).

Filtering by other headers like `X-GitHub-Reason' allows to quickly get rid of noise which doesn't need to be stored for long time, and filtering by subject is not always possible - it may change too often for the same type of messages. LinkedIn, for example, has at least 8 different subjects which all represent the same class of messages.

Filtering by X-Span-Score is also quite useful sometimes, it is very convenient to quickly get through all messages that have score of 15 or more, then go with lower score etc. as no spam filter is perfect and manual filtering sometimes necessary.

Code of Conduct