29 November 2026
How automatic SMS messages are sent, for example for user verification
From clicking “Send code” to the text on your phone: how SMS verification works, what it costs and how to prevent abuse and cost traps.

Anyone who signs up in an app or on a website often receives a text message with a code a few seconds later. What looks like magic is a clearly defined process between your application, an SMS gateway and the mobile network. This article explains it step by step and shows what you need to secure so that verification does not become a cost risk or a security hole.
The process in six steps
- Collect the number. The user enters their mobile number. The application converts it to the international format (E.164, for example
+436609206000) and checks that it is plausible. - Generate the code. The server – never the browser – generates a random code, usually six digits, using a cryptographically secure random number generator. Only a hash is stored, together with the expiry time and a counter for failed attempts.
- Call the gateway. The application sends an HTTPS request to the API of the SMS gateway: recipient, sender, text and a secret access key.
- Delivery. The gateway hands the message to a mobile network, either directly or through an intermediary. The network delivers it to the phone.
- Check the code. The user types in the code. The server compares it and checks the expiry time and the number of attempts.
- Finish. The code is invalidated immediately and the number counts as verified.
In parallel, the gateway usually reports back a delivery receipt, by webhook or on request. “Delivered” does not mean anyone has read the message, and “not delivered” does happen: phone switched off, poor reception, a network problem. The application therefore always needs a way to request the code again.
What an SMS gateway is
An SMS gateway is the service that hands messages from software over to the mobile networks. The SMS API is the interface your application uses to control that gateway, usually as a REST call over HTTPS, and for very high volumes also via the SMPP protocol. Many providers add a web portal and email-to-SMS for sending without programming.
There are two fundamentally different routes:
- Cloud gateway: you pay per SMS and the provider takes care of the network connection and routing. This is the normal case.
- Your own hardware: a device with a SIM card in your own network, or a smartphone acting as a gateway. This suits internal alerts or tests, less so registrations with thousands of users. Throughput and reliability then depend on the device and the mobile contract, and your tariff must allow automated sending.
Technical details that often surprise people
- Sender: the sender shown is either a company name of at most eleven characters or a phone number. A name looks trustworthy but cannot be replied to. Depending on the destination country, special rules apply or the name is replaced. Check this for every country you send to.
- Length: one SMS holds 160 characters. A single emoji or a rare special character cuts that to 70, and longer texts are split into several messages and billed separately. A code needs only one short line.
- Delivery route: going directly to the network operators is usually faster and more reliable, going through intermediaries is often cheaper. For time-critical codes the extra cost is more worthwhile than for mere notifications.
- Number format: always store numbers in E.164 format. With spaces, brackets or a leading zero, messages often do not arrive.
Security: where verification goes wrong
An SMS verification is quick to build and quick to build badly. Five points belong on every checklist:
- Handle the code safely. Six digits from a secure random number generator, valid for only a few minutes (five to ten), usable only once. Limit the number of attempts, for example to five, and store only the hash.
- Limit sending. Only a few codes per hour per phone number, per device and per IP address, plus a waiting time before sending again. Add a daily and monthly budget that puts the brakes on at the provider or in the application.
- Prevent SMS pumping. In this fraud scheme attackers use bots to trigger masses of codes to expensive foreign numbers that they profit from. You pay the bill. Countermeasures: allow only countries where you really have customers, run a bot check before sending (such as a captcha or a background computation) and apply the cost cap from point 2.
- Know the limits of SMS. Codes can be bypassed through SIM swapping, interception or real-time phishing. The US standard NIST SP 800-63B therefore classes SMS codes as “restricted”. For sensitive accounts, passkeys or an authenticator app belong first, and SMS serves as a fallback or to confirm the number.
- Keep the message plain. The reason, the code, how long it is valid and a reminder not to share it. No advertising and no links that make phishing easier.
Law and data protection in Austria and the EU
- A mobile number is personal data. The gateway processes it on your behalf. You need a data processing agreement (Art. 28 GDPR), a list of sub-processors and clarity about where the data is processed.
- Providers outside the EU are only possible with a legal basis for the transfer, such as standard contractual clauses or the EU-US Data Privacy Framework. The Data Privacy Framework is being challenged. If you want to avoid that risk, choose a provider that processes data in the EU.
- Purpose limitation: a verification text must not contain advertising on the side. Advertising texts require prior consent (in Austria section 174 of the Telecommunications Act 2021). Do not quietly reuse the number for later campaigns either.
- Retention: decide how long numbers and sending logs are kept, and delete them afterwards.
What does an SMS cost?
With the large cloud providers, an SMS to Germany currently costs about 7 to 10 cents net. The US platforms are at the upper end, European specialists tend to be below (as of 27 November 2026 according to the comparison named below). Depending on the provider, there may also be base fees, minimum top-ups or charges for your own sender numbers. Destinations abroad are more expensive, and codes requested again count too.
A worked example: 1,000 registrations a month at 8 cents each come to 80 euros. If 20 percent of users request a second code, it is around 96 euros. With a lot of traffic it is worth offering passkeys or email confirmation as the default and using SMS only where it is really needed.
How to choose a provider
The price is only one of several questions:
- Where is the data processed, and is there a data processing agreement?
- How do messages get into the network (directly or through intermediaries), and are delivery receipts free?
- Which senders are possible, and what applies in your destination countries?
- What contract commitment is there, and does credit expire?
- How good are the documentation, the test environment and the support?
- Are there filters and cost limits against abuse?
For orientation: the global platforms include Twilio, AWS and Infobip, and the European specialists include websms, GatewayAPI and SMSAPI, plus further providers in Germany. We do not derive a ranking from this: the right provider depends on destination countries, volume and data protection requirements.
Ready-made building blocks instead of building it yourself
Many sign-in systems already include the connection. Auth0 or Supabase Auth can send codes through common SMS providers, in some cases through a provider of your own. That way you do not have to write code generation, expiry and checking yourself, and part of the protection from the section above is already built in. Still check the limits, countries and cost caps in the configuration.
How we help
We develop web apps, internal tools and client portals and connect sign-in, notifications and interfaces. We advise on the choice between SMS, passkeys and email, choose a provider with you based on data protection and cost, and secure the process against abuse. Get in touch.
Sources
- LOX24: SMS gateway & SMS API comparison 2026 (as of 27 November 2026, retrieved on 28 November 2026; the page is in German). The comparison comes from an SMS provider. We use it for the price range and the market overview, not as a recommendation. Prices change; the provider’s own page is authoritative.
- NIST Special Publication 800-63B, Digital Identity Guidelines (authentication).
- Telecommunications Act 2021 (Telekommunikationsgesetz 2021), section 174, in the Austrian Federal Legal Information System (RIS).

