Storing Dovecot Sieve scripts with SQL database

1

0

I'm not sure how to set up Dovecot to use SQL database for sieve storage. So far I found Pigeonhole with this tutorial - https://wiki.dovecot.org/Pigeonhole/Sieve/Configuration/Dict

From what I understand the idea here is to use dictionary with Sieve scripts stored in SQL database. But one sentence is not clear from me

As with the flat file, the database query will need to return the Sieve script all in one line, otherwise the subsequent lines will be ignored.

So in that case is it possible to retrieve only sieve scripts for given email? I'm trying to find a way to have let say 100 different scripts for 100 different emails. So some would look like this:

require ["envelope", "fileinto", "mailbox"];
if envelope "To" "personal@example.com"
{
    fileinto :create "Personal";
}

another like that

 require ["envelope", "fileinto", "mailbox"]; 
 if envelope "To" "office@example.com" 
 {
     redirect :copy "office@example.net";
 }

But always To would be different.

sebap123

Posted 2018-11-14T19:27:16.470

Reputation: 113

Answers

0

I don't have your environment, so I will try to answer based on general database knowledge. Here is how I understand the documentation in your link.

I believe that the documentation refers to an SQL database (which product?) connected-to with the connection string of:

host=localhost dbname=dovecot user=dovecot password=password

This means that the database server should be running on the same computer, the database to be named dovecot, and have a user account named dovecot with the password of password. I assume that these can be changed, as the connect string is an updateable parameter of the script.

The database should contain a table named user_sieve_scripts, which could maybe be a parameter coming from the configuration file.

The table should have two columns (maybe also configuration parameters):

  • username : The key to be searched, which in your case would be the to field,
  • id : The column which contains the script to use.

The script must be entirely contained within the id column, because only one database access will be done on the table, so this column must be large enough to contain your longest script.

The id column presumably includes line-feeds between lines, or none if the script language supports multi-command lines (I don't know this product well enough).

I hope that this can point you in the right direction.

harrymc

Posted 2018-11-14T19:27:16.470

Reputation: 306 093