General discussion on installation and configuration of SOGo

Text archives Help

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

Chronological Thread 
  • From: André Rodier ( ) < >
  • To: Sogo Mailing list < >
  • Subject: [SOGo] Milter to link email sender and SOGo address book
  • Date: Thu, 08 Aug 2019 22:42:45 +0100
  • Dmarc-filter: OpenDMARC Filter v1.2.0 E59051DE5080

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
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:

I initially wrote this for HomeBox¹, I may add some documentation for
the deployment if needed.

Kind regards,

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.

Archive powered by MHonArc 2.6.18.

Top of page