Reliable OTP and Order SMS for Bangladeshi Businesses
A developer guide to transactional SMS: background queues, retries, OTP security and message logging with gateways like MiM SMS.

Send SMS from a Queue
Calling an SMS gateway during a web request is a common mistake. If the gateway is slow, your checkout becomes slow too, and if it fails, the customer may see an error for an order that succeeded. The better approach is to save the order, push the message to a background queue, and return immediately. Laravel queues or BullMQ with Redis both handle this well, with retries and a delay between attempts.
Protecting OTP Endpoints
Every OTP costs money, so an unprotected endpoint can quickly empty your balance. Limit requests per phone number and per IP address, and add a cooldown before a code can be resent. Store only a hash of the code, expire it within a few minutes, and allow only a few attempts. Generate codes with a cryptographically secure random function rather than a basic random helper.
Templates, Logs and Costs
Keep message text in templates so that support staff can change wording without a deployment. Remember that Bangla text uses Unicode, which fits fewer characters into each SMS part, so a long message can cost several credits. Log the provider’s response for every message, because “the customer never got the SMS” is much easier to investigate with a record. Also separate transactional and promotional messages, since customers should be able to opt out of marketing but never out of an OTP.
Watch your balance and your logs
SMS is one of the few features with a direct running cost. Keep a log of every message with its status and cost, and set an alert for low balance, because an empty account means nobody can log in with OTP. In my school system, messages go through a queued job, so a gateway problem delays a text and never blocks the staff member using the screen.