Hello, thank you for your reply but it appears that it is not an indexing problem. I removed completely /mail/domain.com/test from the filesystem, so now the user folder is no more existent and I let dovecot to recreate it. But it has the same behavior.
I tried to uncomment "crypt_global_private_key main" with crypt_global_private_key main { }
and lmtp gives the following error: pop dovecot[141411]: lmtp(raw-mail-user)<141475><>: Debug: Loading modules from directory: /usr/lib64/dovecot pop dovecot[141411]: lmtp(raw-mail-user)<141475><>: Debug: Module loaded: /usr/lib64/dovecot/lib10_mail_crypt_plugin.so pop dovecot[141411]: lmtp(raw-mail-user)<141475><>: Debug: Module loaded: /usr/lib64/dovecot/lib10_quota_plugin.so pop dovecot[141411]: lmtp(raw-mail-user)<141475><>: Debug: Module loaded: /usr/lib64/dovecot/lib90_sieve_plugin.so pop dovecot[141411]: lmtp(141475): Debug: Effective uid=0, gid=0, home=/run/dovecot/empty pop dovecot[141411]: lmtp(141475): Debug: mail_crypt_plugin: crypt_user_key_curve setting missing - generating EC keys disabled pop dovecot[141411]: lmtp(141475): Debug: User session is finished pop dovecot[141411]: lmtp(141475): Fatal: Raw user initialization failed: mail_crypt_plugin: main: Couldn't parse private key : Unknown key format
if I comment "crypt_global_private_key main": #crypt_global_private_key main { #}
lmtp works and I can receive the email (encrypt and save): pop dovecot[141295]: lmtp(test@domain.com)<141309><Ah2dFvLC42f9JwIAOlru6Q>: Debug: Mailbox INBOX: Mailbox opened pop dovecot[141295]: lmtp(test@domain.com)<141309><Ah2dFvLC42f9JwIAOlru6Q>: Debug: Mailbox INBOX: Adding field flags to cache for the first time (uid=0) pop dovecot[141295]: lmtp(test@domain.com)<141309><Ah2dFvLC42f9JwIAOlru6Q>: Debug: Mailbox INBOX: Saving mail: Opened mail because: header Message-ID (Cache file is unusable) pop dovecot[141295]: lmtp(test@domain.com)<141309><Ah2dFvLC42f9JwIAOlru6Q>: Debug: dict(file): dict created (driver=file) pop dovecot[141295]: lmtp(test@domain.com)<141309><Ah2dFvLC42f9JwIAOlru6Q>: Debug: dict(file): Looking up 'priv/20db4325fcc1e367c82702003a5aeee9/vendor/vendor.dovecot/pvt/crypt/privkeys/fddaf2cd14e50ae3826d4beb07723b6658da2b04a6f2167388197fbf23750d1f' pop dovecot[141295]: lmtp(test@domain.com)<141309><Ah2dFvLC42f9JwIAOlru6Q>: Debug: dict(file): Lookup finished for 'priv/20db4325fcc1e367c82702003a5aeee9/vendor/vendor.dovecot/pvt/crypt/privkeys/fddaf2cd14e50ae3826d4beb07723b6658da2b04a6f2167388197fbf23750d1f': not found pop dovecot[141295]: lmtp(test@domain.com)<141309><Ah2dFvLC42f9JwIAOlru6Q>: Debug: Mailbox INBOX: Adding field hdr.Message-ID to cache for the first time (uid=0) pop dovecot[141295]: lmtp(test@domain.com)<141309><Ah2dFvLC42f9JwIAOlru6Q>: Error: Mailbox INBOX: Saving mail: read() failed: read(/mail/domain.com/test/tmp/1742979826.M389394P141309.pop.domain.com) failed: Decryption error: no private key available (read reason=) pop dovecot[141295]: lmtp(test@domain.com)<141309><Ah2dFvLC42f9JwIAOlru6Q>: Debug: Mailbox INBOX: Purging (new file_seq=1742979826): creating cache pop dovecot[141295]: lmtp(test@domain.com)<141309><Ah2dFvLC42f9JwIAOlru6Q>: Debug: Mailbox INBOX: Purging finished, file_seq changed 0 -> 1742979826, size=0 -> 452, max_uid=0 pop dovecot[141295]: lmtp(test@domain.com)<141309><Ah2dFvLC42f9JwIAOlru6Q>: Debug: Mailbox INBOX: Mailbox opened pop dovecot[141295]: lmtp(test@domain.com)<141309><Ah2dFvLC42f9JwIAOlru6Q>: msgid=unspecified: saved mail to INBOX pop dovecot[141295]: lmtp(test@domain.com)<141309><Ah2dFvLC42f9JwIAOlru6Q>: Debug: Local delivery finished successfully
as you can see there is an error about a lookup of a priv key but however email can be encrypted and saved. I think that it is normal that it can be saved and encrypted as doevoct shoud use just the pub key for encrypting, but why does dovecot search for a priv key?
Now, if I try to read it by imap: pop dovecot[141384]: imap(test@domain.com)<141391><qm1jNTsxvpusHUKZ>: Debug: dict(file): Looking up 'priv/20db4325fcc1e367c82702003a5aeee9/vendor/vendor.dovecot/pvt/crypt/privkeys/fddaf2cd14e50ae3826d4beb07723b6658da2b04a6f2167388197fbf23750d1f' pop dovecot[141384]: imap(test@domain.com)<141391><qm1jNTsxvpusHUKZ>: Debug: dict(file): Lookup finished for 'priv/20db4325fcc1e367c82702003a5aeee9/vendor/vendor.dovecot/pvt/crypt/privkeys/fddaf2cd14e50ae3826d4beb07723b6658da2b04a6f2167388197fbf23750d1f': not found pop dovecot[141384]: imap(test@domain.com)<141391><qm1jNTsxvpusHUKZ>: Error: Mailbox INBOX: UID 1: read() failed: read(/mail/domain.com/test/cur/1742979826.M389394P141309.pop.domain.com,S=3172,W=3228:2,S) failed: Decryption error: no private key available (read reason=header stream) pop dovecot[141384]: imap(test@domain.com)<141391><qm1jNTsxvpusHUKZ>: Disconnected: FETCH failed: UID 1: read() failed: read(/mail/domain.com/test/cur/1742979826.M389394P141309.pop.domain.com,S=3172,W=3228:2,S) failed: Decryption error: no private key available (read reason=header stream) in=214 out=992 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
and then I cannot read email by imap protocol.
Now, if I uncomment again: crypt_global_private_key main { } I can read succesfully the email by imap process. And this time in the log file I don't read anything about any lookup of private keys, but it works correctly. In this situation I cannot receive again any email as lmtp process gives again the error about parsing the key.
Please note that both priv and pub keys are in LDAP, then they can be succesfully read. Priv key can be opened just during an imap session as the password is read during the imap session as user authenticates himself and then he gives the password that is needed to open the priv key.
Any suggestion?