General discussion on installation and configuration of SOGo

Text archives Help


Re: [SOGo] Milter to link email sender and SOGo address book


Chronological Thread 
  • From: André Rodier ( ) < >
  • To:
  • Subject: Re: [SOGo] Milter to link email sender and SOGo address book
  • Date: Fri, 09 Aug 2019 08:20:39 +0100
  • Dmarc-filter: OpenDMARC Filter v1.2.0 mail.inverse.ca 46B4F1DE50D6

On Thu, 2019-08-08 at 22:42 +0100, André Rodier wrote:
> As promised, a little bit late, due to urgent work and holidays.
>
> So, this is a very simple milter, written in Python, that do the
> following when a new message arrive.
>
> 1. Get the recipient uid "UID" from the email address.
> 2. 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:
>
> The header contains a list written for instance "SOGo:Personnal,
> SOGo:
> Professional", it should be, in theory, possible to add other address
> books, like RoundCube or an LDAP directory, with the same header.
>
> 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-abook.py
>
> I initially wrote this for HomeBox¹, I may add some documentation for
> the deployment if needed.
>
> Kind regards,
> André
>
> PS: I do not understand the subtleties of the SOGo address book
> schema
> in the database, but it looks like a very weird implementation
> without
> any SQL principle in mind. I think this is probably now too late to
> rewrite the database schema to something convenient.
>
> PPS: If anyone knows an RFC that specify a header name that contains
> the source address book of a message sender, I am happy to change the
> header name. Otherwise, maybe I may submit an RFC draft.

I have submitted a future request in SOGo ITS, with the same screenshot
attached.

The code is GPLv2, and easy to integrate as a systemd service.

Kind regards,
André

Attachment: abook-based-filter.png
Description: PNG image




Archive powered by MHonArc 2.6.18.

Top of page