How I Built a Cheap SMS Gateway for Reliable 2FA Testing in India

A practical, low-cost approach to building a local SMS gateway for testing 2FA and message flows—what works in India, and what doesn't.

Written by: Rohan Deshpande

Hands holding a smartphone showing a text message thread
Image credit: Unsplash / Drew Beamer

I needed a reliable way to test OTP flows and inbound SMS handling for a payments app we were building in India. Using third‑party sandboxes was fine for unit tests, but they never caught quirks that only show up with real, delayed, or carrier‑filtered SMS. Buying a full aggregator integration just for dev work felt wasteful. So I built a cheap, local SMS gateway that works for day‑to‑day testing—and learned a few limits the hard way.

This is what I built, why I picked each piece, and when you absolutely shouldn’t use this approach for production.

Why not just use Twilio or MSG91?

The options I considered

What I actually built (short recipe)

  1. Old Android phone (₹3,000–6,000) or spare device.
  2. Install an SMS‑forwarder app (I used an open project that forwards SMS to a webhook over HTTPS) or a small Termux script that listens to SMS broadcasts and posts JSON to my dev server.
  3. Dev server (local machine or a cloud dev host). I created a small endpoint /sms-receive that accepts POSTs with {from, body, timestamp}.
  4. For sending tests, I used the same phone with a prepaid SIM. For scale or parallelism, I later added a ₹1,500 4G USB GSM modem on a Raspberry Pi running smsd/gammu and a simple relay.

How the flow works

Why this worked for me

Real constraints and tradeoffs

Practical tips and gotchas

When to stop and use an aggregator

A note about security Treat the device as infrastructure: keep the forwarding token secret, rotate it when people leave, and don’t expose the device directly to the public internet. The easiest path is point the phone at your dev staging server on a VPN or use an SSH reverse tunnel.

Final thoughts Building a cheap SMS gateway taught me more about how OTP delivery actually behaves across Indian carriers than any sandbox ever did. It’s imperfect—flaky hardware, compliance limits, occasional phantom delays—but for daily development and QA it’s a productivity multiplier. Use it to catch the weirdness sandboxes miss, but don’t mistake it for a production strategy.

If you want, I can share the minimal webhook script I use (Node/Express) and the Termux/Android settings I prefer. It saved me hours when reproducing a nasty race condition with delayed OTPs.