We tend to think of "Email" as one thing. But under the hood, it is a fractured mess of conflicting standards.
Gmail prefers its RESTful Gmail API.
Outlook pushes the Microsoft Graph API.
Yahoo/Legacy relies on IMAP (Internet Message Access Protocol), which dates back to 1986.
My goal was to build an Email Aggregator that treated all these protocols as equals. I wanted to build a Universal Mail Client where the user couldn't tell the difference.
Here is the engineering approach I took to unify them.
- The "Middleware" Approach I couldn't just write spaghetti code for each provider. I built a client-side "Translation Layer."
This layer takes the JSON response from Graph API and the binary stream from IMAP and converts them into a single, normalized data object: Universal Message.
This allows the UI to render all mail in one email list without caring about the source.
- Handling the "State" (Smart Sync) IMAP is "stateful" (it keeps a connection open). REST APIs are "stateless." Mixing them destroys battery life.
I implemented a Smart Email Sync engine that forces the stateful protocols to behave more like modern APIs. It batches the requests. This provides One-Click Email Access that feels instant, even if the backend is talking to a legacy server.
- The "Auth" Fragmentation Authentication is the hardest part.
Outlook uses Azure AD tokens.
Gmail uses Google Identity.
IMAP uses... well, sometimes SASL, sometimes plain text (scary).
To build a Secure Email Client, I had to build a secure vault that could handle all mail login types. It encrypts and rotates keys automatically. This reduces "Token Expiry" errors, which is the main cause for users needing all mail recovery steps.
The Result: Complexity Hidden by Simplicity
The result of this heavy backend engineering is "mail App - All Mail Anywhere"
To the user, it is just a simple all mail app They add accounts and get all mail access But underneath, it is a complex translation engine running in real-time.
If you are building an aggregator, don't fight the protocols. Translate them.
Check out the app built on this architecture: https://play.google.com/store/apps/details?id=com.allmail.anywhere.inbox
Top comments (0)