Skip links

2FA OTP SMS

Secure & Stable SMS Gateway

mobtexting's 2FA OTP services are designed for instant delivery of codes via text messages. It is ideal for businesses that provide the highest level of security for the customers. Setup Automatic SMS Alerts/OTPs emails by Integrating With APIs.

Best Practices of OTP SMS

Whether you are establishing a new business or updating your current infrastructure, you can rely on OTP SMSs.

SMS OTP Service

Voice OTP Service

WhatsApp OTP Service

How OTP Solutions Can Help Your Business

Contact Number Confirmation

Verifies the mobile number of the users by sending OTP verification code during the registration. It eliminates fake registrations.

OTP Protected Transactions

No more passwords! Use our API to integrate and let your customers verify themselves every time they log into your system with a short OTP.

Account Confirmation & Recovery

OTP-based account login is the safest method to access the accounts, it generates one time password each time the user login.

Password less Authentication

No more passwords! Let your customers verify themselves every time they log into your system with a short OTP.

How It Works ?

Powerful Capabilities Via Simple APIs

Use any programming language to easily integrate two-factor authentication into your business workflows, ERP, CRM and app.

				
					<?php
                $sms = 'message content';
                $ch = curl_init();
                $post = [
                'access_token'=> 'xxxxxxxx',
                'to'             => '91XXXXXXXXXX',
                'service'       => 'T',
                'flash'         => 0,
                'sender'         => 'XXXXXX',
                'message'     => $sms
                ];

                $ch = curl_init('portal.mobtexting.com/api/v2/sms/send');
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

                $response = curl_exec($ch);
                curl_close($ch);
              var_dump($response);
				
			
				
					use NotificationChannels\Mobtexting\MobtextingChannel;
use NotificationChannels\Mobtexting\MobtextingSmsMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [MobtextingChannel::class];
    }

    public function toMobtexting($notifiable)
    {
        return (new MobtextingSmsMessage())
            ->text("Your {$notifiable->service} account was approved!");
    }
}
				
			
				
					Usage (send SMS)

public class MainActivity extends AppCompatActivity implements MobtextingInterface{
    private Mobtexting mobtexting;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        //create instance of Mobtexting class
        mobtexting=new Mobtexting(this);
        
        //send the SMS
        mobtexting.sendSMS("This is a test","7488******",this);
    }

    @Override
    public void onResponse(ServerResponse serverResponse) {
        Log.d("response",serverResponse.getStatus()+"  "+serverResponse.getDescription()+"  "+serverResponse.getSmsId());
    }

    @Override
    public void onError(ModelError modelError) {
        Log.d("response",modelError.getStatus()+"  "+modelError.getDescription());
    }
}

Usage (how to verify OTP)

Step 1. Generate six digit random OTP in MainActivity class.

public class MainActivity extends AppCompatActivity implements MobtextingInterface{
    private Mobtexting mobtexting;
    private String otp_sixdigit;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //Generate six digit OTP
        otp_sixdigit=String.valueOf(generateSixDigitRandomNumber());

        mobtexting=new Mobtexting(this);
        mobtexting.sendSMS("This is a test "+otp_sixdigit,"7488792140",this);
    }

    //Generate 6 digit number
    private int generateSixDigitRandomNumber(){
        Random rnd = new Random();
        int n = 100000 + rnd.nextInt(900000);
        return n;
    }

    @Override
    public void onResponse(ServerResponse serverResponse) {
        Log.d("response",serverResponse.getStatus()+"  "+serverResponse.getDescription()+"  "+serverResponse.getSmsId());

        //pass the 6 digit OTP to OTPActivity class
        Intent intent=new Intent(getBaseContext(),OTPActivity.class);
        intent.putExtra("otp",otp_sixdigit);
        startActivity(intent);
    }

    @Override
    public void onError(ModelError modelError) {
        Log.d("response",modelError.getStatus()+"  "+modelError.getDescription());
    }
}


Step 2. After successful response, pass the generated OTP to OTPActivity class.


public class OTPActivity extends AppCompatActivity {
    private EditText otpEditText;
    private Button btnVerify;
    private String otp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_otp);

        otpEditText = (EditText) findViewById(R.id.otpEditText);
        btnVerify = (Button) findViewById(R.id.btnVerify);

        //receive the 6 digit generated OTP from previous activity
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            otp = extras.getString("otp");
        }

        //button click listener
        btnVerify.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //check the OTP verification
                if ((otp != null) && (otp.equals(otpEditText.getText().toString().trim()))) {
                    Log.d("verified","OTP verified successfully.");
                }else{
                    Log.d("verified","OTP verified not successfully");
                }
            }
        });
    }
}


Usage (Auto verififcation OTP)
Step 1. Create one Interface class like SmsListener


public interface SmsListener {
    public void messageRceived(String messageText);
}


Step 2. Create one Broadcast receiver class like SmsReceiver


public class SmsReceiver extends BroadcastReceiver{
    private static SmsListener smsListener;
    @Override
    public void onReceive(Context context, Intent intent) {
        try {
            Bundle data = intent.getExtras();

            Object[] pdus = (Object[]) data.get("pdus");
            for (int i = 0; i < pdus.length; i++) {
                SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) pdus[i]);
                String sender = smsMessage.getDisplayOriginatingAddress();
                if (sender != null) {
                    String messageBody = smsMessage.getMessageBody();
                    String msgLower = messageBody.toLowerCase();
                    smsListener.messageRceived(msgLower);
                }
            }
        }catch (Exception e){
            smsListener.messageRceived("something went wrong!");
        }
    }

    public static void bindListener(SmsListener listener) {
        smsListener = listener;
    }
    
    
    
Step 3. Bind the interface to the OTPActivity class


@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_otp);

        otpEditText = (EditText) findViewById(R.id.otpEditText);
        btnVerify = (Button) findViewById(R.id.btnVerify);

        //receive the 6 digit generated OTP from previous activity
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            otp = extras.getString("otp");
        }

        //sms receiver to auto verification
        SmsReceiver.bindListener(new SmsListener() {
            @Override
            public void messageRceived(String messageText) {
                try {
                    String sixOTPDigit = extractDigits(messageText);
                    otpEditText.setText(sixOTPDigit);
                }catch (Exception e){
                    Log.d("exception", "Something Went Wrong!");
                }
            }
        });


        //button click listener
        btnVerify.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //check the OTP verification
                if ((otp != null) && (otp.equals(otpEditText.getText().toString().trim()))) {
                    Log.d("verified","OTP verified successfully.");
                }else{
                    Log.d("verified","OTP verified not successfully");
                }
            }
        });
    }

    /**
     * extract digit from string
     * @param in
     * @return
     */
    public static String extractDigits(final String in) {
        final Pattern p = Pattern.compile( "(\\d{6})" );
        final Matcher m = p.matcher( in );
        if ( m.find() ) {
            return m.group( 0 );
        }
        return "";
    }
}


Step 4. register the broadcast receiver class in android manifest file xml



<receiver android:name=".receivers.SmsReceiver">
    <intent-filter>
      <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
</receiver>

				
			
				
					var mobtexting = require('mobtexting-nodejs')

var access_token = 'xxxxxxxxxxxxxxx'

var client = new mobtexting(access_token)

client.send(
        to="1234567890",
        from="MobTxt",
        body="Hello from nodejs!",
        service="P",
        function(result) {
                console.log(result)
        }
);
				
			
				
					import com.mobtexting.sms.Client;

public class Hello {
    public static final String ACCESS_TOKEN = "xxxxxxxxxxxxxxxxxx";
    
    public static void main(String[] args) {
        Client client = new Client(ACCESS_TOKEN);
        String to = "1234567890";
        String from = "MobTxt";
        String body = "Hello from Java!";
        char service = 'P';
        String response = client.send(to, from, body, service);
        System.out.println(response);
    }
}
				
			
				
					Installation

You can install the package via pip :

pip install git+git://github.com/mobtexting/mobtexting-python.git --user

Send SMS Usage

from mobtexting.client import Client

access_token = 'xxxxxxxxxxxxxxxxxx'

client = Client(access_token)

response = client.send(
    to="1234567890",
    _from="MobTxt",
    body="Hello from Python!",
    service="P"
)

print response.json()

Verify Usage

from mobtexting.verify import Verify

access_token = 'xxxxxxxxxxxxxxxxxx'

verify = Verify(access_token)


Send

response = verify.send(
    to="1234567890",
)

print response.json()


With optional paramaters

response = verify.send(
    to="1234567890",
    data = {
        'length': 4,
        'timeout': 600
    }
)

print response.json()

Check

response = verify.check(
    id='b51be650-fdb2-4633-b101-d450e8d9ec64', # id received while sending
    token='123456' # token entered by user
)

print response.json()


Cancel

response = verify.cancel(
    id='4e28e081-2900-4523-aed6-a21eb39c2ae6' # id received while sending
)

print response.json()
				
			
				
					require "mobtexting_sms"

access_token = 'xxxxxxxxxxxxxxxxx'

client = MobtextingSms::Client.new(access_token)
response = client.send(
        '1234567890', # to phone number
        'MobTxt', # sender
        'hello from ruby!', # message body
        'P' # service
)

puts(response)

Verify Usage

Send

verify = MobtextingSms::Verify.new(access_token)
response = verify.send('1234567890') # to phone number
puts(response)

Check

verify = MobtextingSms::Verify.new(access_token)
response = verify.check(
	'705f1cd4-93e0-492e-b6f8-ffdf9dac68f5', # id received while send
	'123456' # token entered by user
)
puts(response)

Cancel

verify = MobtextingSms::Verify.new(access_token)
response = verify.cancel('705f1cd4-93e0-492e-b6f8-ffdf9dac68f5') # id received while send
puts(response)
				
			
				
					package main
import "fmt"
import client "github.com/mobtexting/mobtexting-go"

func main() {
        var to = "1234567890"
        var from = "MobTxt"
        var body = "hello from go"
        var service = "P"
        var access_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"

        var response = client.Send(to, from, body, service, access_token)

	fmt.Println(response)
}

Verify Usage

Send

var to = "1234567890"
var access_token = "xxxxxxxxxxxxxxxxx"
var response = client.VerifySend(to, access_token)
fmt.Println(response)


Check

var id = "b51be650-fdb2-4633-b101-d450e8d9ec64", // id received while sending
var token = "123456" // token entered by user
var access_token = "xxxxxxxxxxxxxxxxx"
var response = client.VerifyCheck(id, token, access_token)
fmt.Println(response)

Cancel

var id = "b51be650-fdb2-4633-b101-d450e8d9ec64", // id received while sending
var access_token = "xxxxxxxxxxxxxxxxx"
var response = client.VerifyCancel(id, access_token)
fmt.Println(response)
				
			
				
					using System;
using MobtextingDotnet;
namespace Yourprojectnamespace
{
  class message
  {
    static void Main(string[] args)
    {
      string access_token = "xxxxxxxxxxxxxxx";
      Sendsms obj = new Sendsms(ACCESS_TOKEN: access_token);
      string to = "9492xxxxxx";
      string from = "mobsat";
      string body = "hello from c# !";
      char service = 'S';
      obj.sendsms(to, from, body, service);
    }
  }
}
				
			
				
					curl --request POST \
               --url {endpoint}/send/json \
               -H 'Authorization: Bearer 209eccd40ee3a2e14af7fe45b21xxx'
               -H 'Content-Type: application/json' \
               --data '{
                 "root": {
                 "type": "A",
                 "flash": 0,
                 "sender": "TXTSMS",
                 "message": "global message",
                 "service": "T",
                 "dlr_url": "http://www.domainname.com/dlr?status={status}",
                 "time": ""
               },
               "nodes": [
               {
                 "to": "919019xxxx2",
                 "custom": "346576-446565-45657-XFTR",
                 "sender": "txtmes",
                 "message": "Message from & json api node 1"
               },
               {
                 "to": "9188xxxxxxxxxx",
                 "custom": "34"
               }
               ]
             }'

				
			
				
					curl -X POST \
         {endpoint}sms/send/xml \
         -H 'Authorization: Bearer 425b8dec5d6b618fa9c08xxxx' \
         -H 'Cache-Control: no-cache' \
         -H 'Content-Type: application/xml' \
         -d '<?xml version="1.0" encoding="UTF-8"?>
         <data>

         <root>
         <dlr_url><![CDATA[http://domain.com/status]]&gt;</dlr_url>
         <message><![CDATA[global message]]&gt;</message>
         <sender>Name</sender>
         <service>T</service>
         <time>2018-07-05 10:30AM</time>
         <type>N</type>
         <flash>0</flash>
         </root>

         <nodes>
         <node>
         <message><![CDATA[this message will be used insted of root]]&gt;</message>
         <sender>Name</sender>
         <to>9190199556xx</to>
         <custom>9190199556xx</custom>
         <custom1>9190199556xx</custom1>
         </node>
         <node>
         <custom>34</custom>
         <to>9188671356xx</to>
         <sender>Name</sender>
         </node>
         </nodes>

         </data>'

				
			

Why mobtexting For Your Communication Needs?

Reliable, Global, Secure & Scalable

10+

Years of Operation

Founded in 2012. Our team have been running well about 10 years and keep going.

24x7

Round the Clock Support

24x7 customer support via phone, e-mail, WhatsApp, Skype, Chat.​

195+

Global Scale

Communicate, connect & engage customers across 195+ countries with unified APIs without any hassle.​

Built for every Business

Big or small, we cater to all. Global & scalable cloud-based platform built for growing business & engineered for reliability & 99.9% uptime.​

Comprehensive Platform

Manage all the communication channels without switching Apps. User-friendly cloud-based web interface & developer-friendly programmable APIs for your business.​

Best In Class Connectivity

Direct operators & APIs connectivity for hassle-free service to businesses to connect their customers faster in a secure way.

Highly Secure

Enterprise-grade security - ISO27001:2022 certified information security management system to our customers.​

Trusted by 1000+ Businesses Across 4 Continents

Most innovative businesses build communication solutions using mobtexting’s platform & APIs. Get started today & engage your customers over their preferred channels across the world.