What I am wondering is if there is an IMAP server available that supports the IMAP SEARCH
command (https://www.rfc-editor.org/rfc/rfc1730#section-6.4.4), and is fast.
I have had a look around at ways that this can be done, including using DBMail to store all of the incoming emails, but to be honest so far what I have found is that most of the IMAP solutions have some sort of downfall - none really seem to be aimed specifically at what I want to do.
For example, DBMail is almost perfect, however it stores attachments in the database. What I would love to have is that inside the database all of the messages (HTML, TXT) are stored, but the attachments are stored somewhere else on the filesystem.