Case study
A company's own mail, chat and calls
Almutakamela ran its mail on a hosted provider. I moved every mailbox onto the company's own mail server and built the workspace in front of it: webmail, chat, voice and video calls, tasks, calendar, files and assets, with one sign-in, plus native apps for iPhone, Android and Windows.
Wael Hanna · FastAPI, Preact, Swift, Kotlin · Oct–Nov 2026
The move
Moving a whole company's mail, live
People kept working through the move. Each mailbox was copied in the background, staff were handed over in batches overnight, and the switch of the company's mail records happened only once everyone was across.
Built for a quiet cut-over
I wrote the tools the move needed: a hand-over script, a parallel copy runner, and a night "autopilot" that moved staff in batches while the office slept.
- A 49 GB Outlook archive of about 70,000 messages was imported with duplicates removed.
- The largest mailbox moved held 153,000 messages.
- Shared group addresses were recreated as aliases before the switch, so no mail went missing.
- After the switch, every old sync job was removed and unknown addresses were refused at the door.
Own webmail goes live for the pilot; tasks built into it.
Public access through the company firewall and reverse proxy. Calls work from outside.
Instant new-mail push, several accounts, encrypted backups every two hours, health checks.
Night autopilot moves staff in batches; 101 people handed over.
The company's mail records switched. The last person moves the same night.
Calendar, HR page, meeting links, asset hand-over sheets, iPhone call ringing and badges.
Mail people actually like using
The webmail was written for this company, in English and Arabic, with the things staff asked for rather than everything a mail client could do.
The inbox
Conversations grouped by subject, including Arabic reply prefixes. Quick filters for unread, attachments, flagged and important, and a search across every folder.
- Pin, tag, snooze until later, send later and undo send.
- "Add as task" on any message, and a Today view of what is due.
- Any attachment opens or saves as PDF, Office files included.
- Bulk send: one personal message per recipient, every 10 seconds, at most 500 a day, with a test to yourself first and a stop button.
- One search box (Ctrl+K) across mail, tasks, assets and chat.
- On every message: forward as attachment, a one-click summary, a WhatsApp reminder, and a meeting made from the mail.
A sign-in page drawn from Dubai
The sign-in card sits on a map of Dubai drawn from OpenStreetMap: the coast, the motorways, and a flag on each of the company's testing centres, with mail travelling between them.
- The map follows the real sun in Dubai: day, dusk and a dark night with glowing roads.
- A weather panel comes through the company's own server, so a visitor's address never reaches a third party.
Chat & calls
Chat and calls on our own servers
Company chat with groups, files and calls, kept on the company's server. It is deliberately not end-to-end encrypted: it is company chat, and the company keeps the record.
Chat with a permanent record
Every mailbox gets a chat account automatically. A custom server module refuses edits and deletions of sent messages, so the history stays as it was written.
Voice, video and screen sharing
One-to-one and group calls, with a relay for networks that block direct connections. The relay only forwards to the company's own server, so it cannot be misused as an open relay.
Mentions, reactions and voice notes
Group chats with pinned messages, @mentions, reactions, voice messages and read markers, and a voice or video call one tap away from any chat.
Calls that ring the phone
A one-to-one call rings an iPhone like a normal phone call, even when the app is closed.
Interview links for guests
HR can send a candidate a meeting link that works without an account, valid from 15 minutes to 24 hours, as video or voice only. The server signs each guest's access itself, with no admin rights.
Tasks
Tasks with a memory
Tasks live inside the webmail and follow the company's reporting lines. A manager sees their team's work, and everyone sees their own.
Nothing disappears
Tasks are never deleted and comments are never edited. The database itself refuses it, so the record of who was asked what, and when, stays complete.
- A task is cancelled with a reason instead of deleted. Putting one on hold needs a reason too.
- People, roles and reporting lines come from the mail admin portal, the only place people are created.
- Task alerts appear as a badge in the webmail and as notifications on the phones.
Company assets
Laptops, phones and equipment with their serial numbers scanned by camera. Hand-overs produce a bilingual sheet that is approved electronically, numbered, fingerprinted and frozen as a one-page PDF. Hand-over records cannot be deleted.
HR and calendar
HR can edit exactly seven staff fields, checked on the server, and every change is logged. The calendar edits only the fields that changed in an event, so attendees and alarms are never lost.
Apps
The same workspace in your pocket
Three native apps, each written for its platform, all talking to the same server API as the web app. Nothing on the server had to change for them.
iPhone, Android and Windows
- Mail, chat, calls, tasks and alerts, with several accounts on one device.
- New mail arrives at once, with Reply, Mark as read and Archive right on the notification, and an unread badge on the app icon.
- Passwords are kept in the iPhone Keychain, Android's encrypted storage, or Windows' own protected storage, one per account.
- The Windows app sits in the tray, shows Windows notifications and updates itself quietly, checking each download's fingerprint.
- The iPhone app also shows the ERP Change Portal natively.
Approvals in your pocket
Purchase requests travel through their approvals on the phone: sent, initial approval, procurement, finance and paid, with each step’s person and date, the items and the total.
Everything on one screen
The Today screen gathers the day’s meetings, unread mail and tasks due, and the tab bar keeps mail, chat and tasks one tap apart, with unread counts on each.
Architecture
How it is built
Open-source building blocks run in containers on one company server, with a thin, hand-written app in front that ties them together under one sign-in.
One lesson from building it: the reverse proxy could not carry compressed websocket frames, so calls connected inside the office but never from outside. Turning compression off for the call signalling path fixed it, and every new websocket behind the proxy now follows that rule. Backups run every two hours, encrypted and incremental, with restore tests that matched byte for byte, and a health check every five minutes.
Security
Security in every layer
Mail is the front door of a company. Each layer assumes the one in front of it might fail.
Passwords at rest
The session's mail password is encrypted with AES-GCM under a key derived from the session id, which only the person's browser cookie holds.
Sign-in protection
Strict, HTTP-only cookies with an eight-hour idle limit, a CSRF header on every change, and limits of 5 failed sign-ins per address and 20 per network per 15 minutes.
Safe message display
Messages are cleaned with an allow-list and shown in a sandboxed frame. Remote images stay blocked until the reader allows them, and attachments are served sandboxed.
Hardened containers
The app runs as a non-root user on a read-only file system with no way to gain privileges, behind a full set of security headers.
A clean mail reputation
Unknown recipients are refused at the door, there is no backup mail server that could bounce spam back, and SPF, DKIM and DMARC are in place.
Forwarding stays inside
Mail rules can forward only to company domains, so a rule cannot quietly send company mail outside.
Decisions
Decisions worth explaining
Small choices that made the system faster, sturdier or easier to keep.
No build step
The front end is plain modules. Anyone can read, change and deploy the files as they are, and the app caches them directly.
Long polling instead of websockets
New-mail push is a plain request the server answers when something changes. It passes every proxy without special rules.
Sort by arrival, not by date
On a mailbox of 22,000 messages, sorting by date took 42 seconds; sorting by arrival took 0.7.
Bulk send marks before it sends
Each message is marked as sending first, because a customer getting the same mail twice is worse than a retry.
One app process
Sessions hold live mailbox connections in memory, so one process serves everyone and stays fast.
The handbook is part of the code
Every change made on a server is written into the system's handbook and copied into the repository the same day, so two people can run it safely.