Hello all,
I am actually writinghave written a milter with Python that can be useful, especially if you are using the Sieve filters. It is written for SOGo, but it should be very simple (even simpler) to translate into RoundCube address books.
This is a very simple milter, written in Python, that do the following when a new message arrive.
"UID" 3. Search the sender email address in all the user's address books 4. If found at least one, add one header "X-AddressBook" which contains a list of all the address books found, with a prefixed syntax:
X-AddressBook: "SOGo:Personnal, SOGo:Professional"
So, in the case of RoundCube, the plugin would use RoundCube prefix, but the same principle.
There are some limitations, of course, but it is still functional.
list of from email address, just create an address book, and a put your contacts in it.
You can create a different automatic responder for each address book.
Because I am using this on Debian Stretch for now, I am using the
available version of python-milter, which uses python2. When I will port this to buster, I will use the python3-milter package. I tried to made it compatible with version 3 as much as I could.
working on it.
idea was to use a global sqlite database synchronised with multiple address books, it was supposed to contain not the email address but a hash (sha256).
code, but it should be readable. I had to disable a few pylint warnings, as I could not solve them at all, especially those related to the inherited class.
The code:
https://github.com/progmaticltd/sogo-milters/blob/master/milter-abook/milter...
I initially wrote this for HomeBox, I may add some documentation for the deployment if needed.
Kind regards, André
On Fri, 2019-08-09 at 11:01 +0100, André Rodier wrote:
Hello all,
I have written a milter with Python that can be useful, especially if you are using the Sieve filters. It is written for SOGo, but it should be very simple (even simpler) to translate into RoundCube address books.
This is a very simple milter, written in Python, that do the following when a new message arrive.
- Get the recipient uid "UID" from the email address.
- Get the list of address books in the database for the user with
uid "UID" 3. Search the sender email address in all the user's address books 4. If found at least one, add one header "X-AddressBook" which contains a list of all the address books found, with a prefixed syntax:
X-AddressBook: "SOGo:Personnal, SOGo:Professional"
So, in the case of RoundCube, the plugin would use RoundCube prefix, but the same principle.
There are some limitations, of course, but it is still functional.
- Once active, sieve filters should be simpler, no need to have a
long list of from email address, just create an address book, and a put your contacts in it.
- You can create a different automatic responder for each address
book.
- Because I am using this on Debian Stretch for now, I am using the
available version of python-milter, which uses python2. When I will port this to buster, I will use the python3-milter package. I tried to made it compatible with version 3 as much as I could.
- This is freshly new, and has not been tested in production yet. I
am working on it.
- You can test the behaviour using an SQLite database. Because my
first idea was to use a global sqlite database synchronised with multiple address books, it was supposed to contain not the email address but a hash (sha256).
- I am not a Python expert, and perhaps there are some errors in the
code, but it should be readable. I had to disable a few pylint warnings, as I could not solve them at all, especially those related to the inherited class.
- This is the first time I am writing a milter script, be indulgent.
The code:
https://github.com/progmaticltd/sogo-milters/blob/master/milter-abook/milter...
I initially wrote this for HomeBox, I may add some documentation for the deployment if needed.
Kind regards, André
OK, this is done, and it was quick.
https://github.com/progmaticltd/roundcube-milters/blob/master/milter-abook/m...
So, the milter creates a header X-AddressBook, with the content like this:
Default address book: X-AddressBook: RoundCube:default Specific group: X-AddressBook: RoundCube:Personal
Code is GPL v2
Database is Postgres, but perhaps can be modified easily to be MySQL or sqlite...
Kind regards, André