Deep Linking Emails in Third Party Apps to Open in WebMail

WebMail Integrations

This article applies for Axigen X1 and higher versions.

Got a third party portal / app where you aggregate multiple types of information for your users? Here's how you can also show emails from their Axigen mailbox.

This article details how to deep-link emails from external applications so that, when clicked, they get opened in the WebMail.

Working assumptions

  • For simplicity, we will take a limited scenario:
    • we only get the last (newest) email, display it in our app and link it to the user's WebMail. Of course, this can be extended to fit with your own criteria.
    • we won't be covering single sign-on in this article — this is something that you will have to do in the background, as for the user we will assume that they will be authenticated based on their login cookie, or will manually log into the WebMail (the deep linking will still apply after login). See here how to set up single sign-on with Axigen WebMail

We assume that you have basic knowledge of IMAP and / or IMAP libraries in your app's programming language — you will use IMAP to display the user's emails in your app.

Fetching the emails and related info via IMAP

In this example, we have userA who has 1 email in her Inbox.

We will manually connect via IMAP — this is something that you will need to do programatically against the WebMail, at the time userA logs into your application.

After login, we do the following operations:

  • Select the desired Axigen folder — in our case, we chose the "Inbox"

    We will need the count of the last email returned by IMAP — in our case, there's only one email, so that count will be also 1: 

  • Fetch the UID of that email — we will need it for our deep link: 

    In our case, the ID returned by the IMAP server is also 1: 

  • Fetch the content of that email so that we can process it and display it in our app:

 

You will notice that the IMAP server returns all the necessary headers, as well as the content of the body, which can be processed and used for building a body snippet.

 

Building the deep-linked URL

You can form the URL as follows:

 

In our case, we used a test server installed in our local network, which we access by IP.

 

As you can see, when accessing this URL in the browser, the WebMail opens it in its own tab.