A fast, focused mail client for TU Sofia mailboxes, with a Bulgarian interface, dark mode by default,
a phone-first layout and new-mail notifications on your phone.
Open Кампус Поща →
Every screenshot and animation in this README uses fictional mail. No real mailbox was shown.
| Folders show TU's real unread counts. Opening a message marks it read in TUSmail, or not, if you turn that off. Search covers sender and subject in the current folder. The list refreshes on entry, on focus and about every minute. | Stars, read/unread, move, archive and trash, one message at a time or in bulk. Every move has an 8-second undo. Permanent delete only from Кошче, after a confirmation. |
| Учебни, Администрация, Събития, Лични, plus your own. Labels are keyed by Message-ID, so they follow a message you move within the app. | Reply, reply all, forward, CC/BCC, attachments and autosaved drafts. Every send has a stable attempt ID: an uncertain SMTP result is never resent automatically, and Запази копие retries only the Sent copy. |
| New mail in Входящи arrives as a notification with the sender and subject, even when the app is closed. Battery use is close to zero: the phone keeps no mail connection of its own. |
Optional sounds for new mail and for sending (made with ElevenLabs), dark/light/system themes, comfortable or compact density, and ? for every keyboard shortcut.
|
![]() |
![]() |
| Light theme | Settings: theme, density, reading, sounds, notifications |
flowchart LR
subgraph Phone["📱 Phone / 💻 Browser"]
UI["Кампус Поща<br/>(Next.js app)"]
SW["Service worker<br/>(notifications)"]
end
subgraph Vercel["▲ Vercel · fra1"]
API["/api/mail/*<br/>sessions, labels, drafts, sends"]
DB[("Neon Postgres<br/>+ private Blob")]
end
subgraph VM["☁️ Oracle VM"]
Relay["kampus-relay<br/>CONNECT tunnel"]
Push["kampus-push<br/>IMAP IDLE worker"]
end
TU[("TU Sofia<br/>IMAPS 993 · SMTP 27")]
FCM["FCM / Apple Push"]
UI <--> API
API <--> DB
API -- "IMAP/SMTP over TLS" --> Relay --> TU
API -. "signed sync" .-> Relay -.-> Push
Push -- "IDLE on INBOX" --> TU
Push -- "sender + subject" --> FCM --> SW
- TU drops all traffic from AWS, which is where Vercel runs. Mail sockets therefore pass through a small, dependency-free CONNECT relay on an Oracle VM. The relay only allows TU's two mail endpoints, and TLS runs end to end, so it never sees mail or passwords.
- Notifications:
- The push worker keeps one IMAP IDLE connection per subscribed account, on INBOX only.
- It fetches headers only, so nothing gets marked read.
- It sends the sender and subject through Web Push.
- A burst of more than three messages is collapsed into one summary notification.
| What | How |
|---|---|
| Sessions | Opaque HttpOnly; SameSite=Strict; Secure cookie, record encrypted with AES-256-GCM. 24 h idle, 7 days max, deleted on Изход. |
| Your mail | Never copied. Each message is read from TU when you open it. HTML is sanitised, remote content is blocked, and HTML renders in a sandboxed iframe. |
| Notification login | Sealed to the push worker's X25519 key (HKDF-SHA256 + AES-256-GCM, bound to your account). Vercel stores it but cannot open it. It is deleted when you turn notifications off, sign out on that device, or after 90 days without a sign-in. |
| Relay | Requires a secret, only allows TU's mail endpoints plus the worker's localhost port, is rate-limited, and is capped by systemd. Passes TLS through untouched. |
| Worker | DynamicUser, ProtectSystem=strict, 192 MB / 20% CPU limits. Listens only on 127.0.0.1 and is reached through the relay, so no new port is open. Sync messages are HMAC-signed and expire after 60 s. |
| Limits | Up to 25 notification accounts, 5 devices each. Pushes go only to known push services (FCM, Mozilla, Apple, WNS). |
Requires Node.js 22 or newer.
npm ci
npm run devOpen tusmail.localhost:3000. To use port 3001 instead, run $env:PORT = '3001' first.
- The server listens on loopback only.
- Sessions are stored encrypted in the ignored
.mail-datadirectory, together with its local key. Keep that directory private.
npm test # 24 tests: IMAP/SMTP fixtures, API, relay, push crypto + worker
npm run buildThe tests run against loopback IMAP/SMTP fixtures, the API handler, a real relay, and a fake IMAP client for the push worker. They use synthetic data only.
Configuration lives in .env.example.
| Piece | Where | Needs |
|---|---|---|
| App + API | Vercel (fra1) |
MAIL_MODE=hosted, TU_HOSTED_APPROVED=yes, MAIL_ORIGIN, TU_ALLOWED_USERS, DATABASE_URL, APP_KEY, BLOB_READ_WRITE_TOKEN, MAIL_PROXY |
| Relay | relay/ on a VM TU accepts |
RELAY_SECRET, RELAY_TARGETS (TU's two endpoints plus 127.0.0.1:8994) |
| Push worker | push/ as systemd kampus-push |
/etc/kampus-push.env. Keys are generated on the VM; only public values and shared secrets go to Vercel (PUSH_*, NEXT_PUBLIC_VAPID_KEY). |
Without the full hosted configuration, every mail route stays off. POST /api/mail/reachability checks, without any credentials, that the deployment can reach both TU ports.
![]()
Кампус Поща is not an official TU Sofia service. The official webmail is tusmail.tu-sofia.bg.




