Tutorial section - SMS

Send SMS with SMPP using C++

Sending SMS with the SMPP API using the C++ programming language
Tyr SMS Gateway

The cpp-smpp library can be used to make SMPP requests using C++. This library can be used to submit SMS to an SMS gateway or SMSC.

SMPP requirements and resources

SMPP is the Short Message Peer-to-Peer protocol for conveying SMS operations. An SMPP client can be used to connect to an SMSC or SMS gatewat using the SMPP protocol. An SMPP account can easily be obtained for using the Tyr SMS Gateway or SMSC Simulator. The following are required to send SMS with SMPP:

C++ requirements and resources

C++ is a programming language and can be used to quickly and easily add SMS support for programmatically sending and receiving SMS messages. Use it for transactional messaging and notifications between your application and mobiles. The following are required to send SMS using C++:

  • C++
    C++ programming language

Requirements and resources

The following are required to send SMS with SMPP using C++:


Create the file transmit.cpp containing the code below. Replace the hostname smscsim.melroselabs.com, port 2775, SYSTEMID and PASSWORD values with those from your SMPP API account. Alternatively, replace SYSTEMID and PASSWORD with those allocated to you for use with the Melrose Labs SMSC Simulator.

The following example C++ code opens an SMPP transmitter bind to smscsim.melroselabs.com on port 2775 (SMPP port), and then sends the message Hello World #$£ to mobile number 447712345678 from MelroseLabs. The message ID returned in $messageID is that returned from the SMS gateway or SMSC after a successful submission. The SMPP system ID and password for the SMPP account are contained in SYSTEMID and PASSWORD respectively.

				#include <smpp/smppclient.h>
#include <smpp/gsmencoding.h>
#include <boost/asio.hpp>
#include <boost/shared_ptr.hpp>
#include <iostream>

using namespace boost;
using namespace boost::asio;
using namespace boost::asio::ip;
using namespace smpp;
using namespace oc::tools;
using namespace std;

int main(int argc, char** argv)
	boost::asio::io_service io_service;
	boost::asio::ip::tcp::resolver resolver(io_service);
	boost::asio::ip::tcp::resolver::query query("smscsim.melroselabs.com", "2775");
	boost::asio::ip::tcp::resolver::iterator iter = resolver.resolve(query);
	tcp::endpoint endpoint = iter->endpoint();
	shared_ptr<tcp::socket> socket(new tcp::socket(io_service));

	SmppClient client(socket);
	client.bindTransmitter("SYSTEMID", "PASSWORD");

	SmppAddress from("MelroseLabs", smpp::TON_ALPHANUMERIC, smpp::NPI_UNKNOWN);
	SmppAddress to("447712345678", smpp::TON_INTERNATIONAL, smpp::NPI_E164);
	string message = "Hello World €$£";
	string smscId = client.sendSms(from, to, GsmEncoder::getGsm0338(message));

	cout << smscId << endl;

	return 0;


	g++ transmit.cpp -I/usr/local/include -lsmpp -lboost_system -lboost_regex -lboost_date_time
Get free SMPP account for SMSC Simulator >

Other APIs covered in our tutorials that can be used for sending and receiving SMS using C++ include: REST

Other languages covered in our tutorials that can be used for sending and receiving SMS with SMPP include: Python, PHP, Java, C#, Perl, Go, Node.js, Ruby

Whatever the language or API, you can send SMS and receive SMS between applications and mobiles for a wide range of uses with a number of our services. Please consider using our Messaging, SMS gateway and Bulk SMS solutions.

If you are interested in testing your application's SMS support and are using the SMPP protocol, then we recommend that you take a look at the Melrose Labs SMSC Simulator service that can simulate SMS message delivery to mobiles (MT SMS) and simulate SMS messages from mobiles (MO SMS). The SMSC Simulator supports SMPP v3.3, v3.4 and v5, and has a high degree of SMPP protocol conformance. Later in 2020 we will be providing access to the Melrose Labs Tyr SMS Gateway for A2P, P2A, bulk, wholesale and business SMS, and for text marketing and other applications. The Melrose Labs Tyr SMS Gateway will support REST and SMPP APIs.

Follow us on LinkedIn for updates on Melrose Labs services and news.

Find out more...

Please provide your name.
Please provide a valid company name.
Please type your message.
Please provide a valid email address.