Catch all for Metadata storage in SQL database

Aki Tuomi aki.tuomi at open-xchange.com
Mon May 3 09:10:04 EEST 2021


> On 30/04/2021 09:38 Steffen Kaiser <skdovecot at smail.inf.h-brs.de> wrote:
> 
>  
> Hi,
> 
> the
> 
> https://doc.dovecot.org/configuration_manual/imap_metadata/
> 
> sample uses
> 
> mail_attribute_dict = file:%h/Maildir/dovecot-attributes
> 
> which stores all keys=value pairs in the file.
> 
> http://dovecot.2317879.n4.nabble.com/Dovecot-v2-3-9-3-HTTP-API-Endpoint-for-mailbox-cryptokey-operations-td70801.html
> 
> uses a SQL dict, however very specific ones. How can I use a SQL dict to 
> store _all_ keys, as with a file based storage?
> 
> I cannot find a documentation for "pattern" specification, that works as 
> "catch all", in order to store anything not catched by patterns into the 
> database.
> 
> https://wiki.dovecot.org/Dictionary does not give any hint (in my eyes).
> 
> 
> 
> -- 
> Steffen Kaiser


for one, you need to use proxy::metadata

then define

dict {
   metadata = mysql:/path/to/config
}

then you need the mapping file, which you could use something like:

connect = host=localhost dbname=dovecot user=dovecot password=dovecot
map {
 pattern = priv/$key
 fields {
   meta_key = $key
 }
 table = meta
 username_field = username
 value_field = value
}

with

CREATE TABLE meta (
   username VARCHAR(255) NOT NULL,
   meta_key VARCHAR(255) NOT NULL,
   value VARCHAR(255),
   PRIMARY KEY(username, `key`)
);

Hope this helps.

Aki


More information about the dovecot mailing list