HomeAPI & DevSend SMS with C++

Send SMS with ⚙️ C++

Send SMS from your C++ application using libcurl — the most reliable cross-platform HTTP library for C++. Supports Windows, Linux, and macOS.

C++ · libcurl HTTPS POST v2.0
ℹ️
Before using the API, register a free iSMS account and purchase SMS credits. See the full SMS API docs for all parameters and error codes.
📦
Prerequisite: Install libcurl. On Ubuntu/Debian: sudo apt install libcurl4-openssl-dev  ·  On Windows: use vcpkg or download from curl.se.
API Endpoints
HTTPS Endpoints — use all 3 for high availability
// Primary
https://smtpapi.vocotext.com/isms_send_all_id.php

// Mirror 2
https://smtpapi2.vocotext.com/isms_send_all_id.php

// Mirror 3
https://www.isms.com.my/isms_send_all_id.php
Send SMS — C++ with libcurl
C++ · libcurl HTTPS POST
#include <curl/curl.h>
#include <iostream>
#include <string>

// Callback to capture response body
static size_t WriteCallback(void* ptr, size_t size, size_t nmemb, std::string* data) {
    data->append((char*)ptr, size * nmemb);
    return size * nmemb;
}

int main() {
    curl_global_init(CURL_GLOBAL_DEFAULT);
    CURL* curl = curl_easy_init();

    if (!curl) {
        std::cerr << "Failed to initialize libcurl" << std::endl;
        return 1;
    }

    std::string postFields =
        "un=your_username"
        "&pwd=your_password"
        "&dstno=601X-XXXXXXX"    // Full international format
        "&msg=Hello+from+iSMS%21" // URL-encode spaces and special chars
        "&type=1"               // 1 = ASCII, 2 = Unicode
        "&agreedterm=YES"
        "&sendid=MyBrand";      // Optional, max 11 chars

    std::string response;

    curl_easy_setopt(curl, CURLOPT_URL, "https://smtpapi.vocotext.com/isms_send_all_id.php");
    curl_easy_setopt(curl, CURLOPT_POST, 1L);
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postFields.c_str());
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);   // Always verify SSL
    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30L);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

    CURLcode res = curl_easy_perform(curl);

    if (res != CURLE_OK) {
        std::cerr << "curl error: " << curl_easy_strerror(res) << std::endl;
    } else if (response.rfind("2000", 0) == 0) {
        std::string trxId = response.substr(response.find(':') + 1);
        std::cout << "SMS sent! Transaction ID: " << trxId << std::endl;
    } else {
        std::cerr << "Failed: " << response << std::endl;
    }

    curl_easy_cleanup(curl);
    curl_global_cleanup();
    return 0;
}

// Compile: g++ send_sms.cpp -lcurl -o send_sms
✅ Success
2000 = SUCCESS:1143007207
// Save the transaction ID for delivery tracking
❌ Error
-1001 = AUTHENTICATION FAILED
-1003 = IP NOT ALLOWED
-1004 = INSUFFICIENT CREDITS
-1008 = MISSING PARAMETER
-1013 = INVALID TERM AGREEMENT
⚠️
Delivery Status Note (Malaysia): A 2000 response confirms submission to Telco SMSC only — not delivery to handset. For confirmed Sent → Received → Read tracking, consider WhatsApp Business API.

Ready to Integrate?

Register free, get your API credentials, and start sending in minutes.

📱 SMS Coverage — All Countries Worldwide

A B C D E F G H I J K L M N O P Q R S T U V Y Z