Extensible James server: predictions in your INBOX

Benoit Tellier
Aug 16, 2017 · 3 min read
Image for post
Image for post

In a previous article, I covered how we used the James mail server to decorate emails with events in the OpenPaaS Inbox webmail.

As a reminder, the James project gives us a working mail server to play with, and customizing the behaviour of this server to implement business features is easy.

At Linagora, as part of the OpenPaaS solution, we heavily rely on the James server, and actively develop features using the functionalities of James. Today I will cover how we added recommandations on emails.

A recommandation is an hint for a possible mail move. The answered question is “In which folder should this mail be?”. The intent is to have automatically defined SIEVE scripts. From a User Interface point of view, a quick move button will be positioned on the global Inbox view next to your emails, if the system assumes the given email should rather belong in another mailbox.

Image for post
Image for post
You can see on the left corner, with the lamp button, some predictions in my mailbox. Clicking the button alongside the email will move it in the specified mailbox.

You can notice that the probability is added as part of the suggestion.

Image for post
Image for post

The overall architecture look like this:

— A model is generated from a dump of the James database. Currently it is using ElasticSearch documents. But this part of the system will likely change in a near future. Every user gets his own prediction model. This is done on a recuring basis using systemd timers.

— The prediction REST API is built on top of the models. By giving details about emails, you get a prediction.

— James, when receiving an email, will call the prediction API. It will add the prediction results as part of the mail headers.

— Inbox can then finally use these headers. It will use these peaces of information to display the move button, and display prediction accuracy.

Under the hood James is using a mailet for executing code upon email reception post processing. We implemented a dedicated mailet for calling the prediction API for every incoming emails, as a OpenPaaS specific James extension.

An implementation difficulty was the need to get user specific headers. We then reworked the Mailet API to add this feature, as well as enhanced message delivery to take these changes into account.

So far, we will need to make the integration evolve:

— The prediction API needs feed-back. It needs to know when a message is effectively moved to get better predictions. To do this, we need to be aware of the James message store updates. It means we need some kind of Mail Delivery Agent (MDA) extensibility. Such extensibility will unlock some new possible user features that can not be achieved with regular Inbound semantic.

— Data ingestion for computing the model will likely change. We will prefer a data-stream comming directly from James.

— We would like to associate a per user threashold for automatically moving emails. If the accuracy is more than the defined threashold, then the email will be directly moved to the given mailbox.

The interconnection of James and Prediction API gave us a great feature. Now every one can get the equivalent of self defined Sieve scripts, without set-up and without any knowledge. It just require you to move emails, and the system will learn from it. Such use case show the potential of the James server, which allow building complex features for email systems.

Linagora Engineering

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store