Tutorial section - SMS
Send SMS with SMPP using PerlSending SMS with the SMPP API using the Perl programming language
Net-SMPP library can be used to make SMPP requests using Perl. This library's higher-level functions can be used to synchronously submit SMS to an SMS gateway or SMSC.
SMPP requirements and resources
SMPP is the Short Message Peer-to-Peer protocol and is used by applications for sending and receiving SMS. An SMPP client can be used to connect to an SMSC or SMS gateway using the SMPP protocol. An SMPP account, including special Developer accounts, can quickly and easily be obtained for using the Melrose Labs Tyr SMS Gateway or SMSC Simulator. The following are required to send SMS with SMPP:
- SMPP Protocol [reference]
Short Message Peer-to-Peer Protocol v3.3, v3.4 and v5 specifications and guides
- SMPP Client [tool]
Browser-based SMPP client supporting SMPP v3.x and v5 via Web Sockets
Perl requirements and resources
Perl 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 Perl:
Perl programming language. Download for Unix/Linux, macOS and Windows.
Requirements and resources
The following are required to send SMS with SMPP using Perl:
Net::SMPP - pure Perl implementation of SMPP 3.4 over TCP
Create the file
sendsms.pl containing the code below. Replace the hostname
PASSWORD values with those from your SMPP API account. Alternatively, replace
PASSWORD with those allocated to you for use with the Melrose Labs SMSC Simulator or the smpp.org SMSC simulator.
The following example Perl 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
MelroseLabs. The message ID returned in
$resp = $smpp->submit_sm() 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
#!/usr/bin/perl # # Usage: ./sendsms.pl use Net::SMPP; use Data::Dumper; #$Net::SMPP::trace = 1; $sysid = "SYSTEMID"; $pw = "PASSWORD"; $host = "smscsim.melroselabs.com"; $port = 2775; $if_vers = 0x34; ### Connect and bind warn "Connecting and binding"; ($smpp, $resp) = Net::SMPP->new_transmitter( $host, port => $port, system_id => $sysid, password => $pw, system_type => "", interface_version => $if_vers, addr_ton => 0x00, addr_npi => 0x00, address_range => "" ) or die "Can't contact server: $!"; ### ### Typical session in synchronous mode ### warn "Sending submit_sm"; $resp = $smpp->submit_sm( source_addr_ton => 0x05, source_addr_npi => 0x00, source_addr => "MelroseLabs", dest_addr_ton => 0x01, dest_addr_npi => 0x01, destination_addr => "447712345678", data_coding => 0, short_message=>"Hello World" ); warn Dumper $resp; $resp = $smpp->unbind(); warn Dumper $resp; warn "Done."; #EOF
Using in production
Whatever the language or API, you can send SMS and receive SMS between applications and mobiles for a wide range of uses with any of the trusted and reliable CPaaS services from Melrose Labs. Take a look at our Messaging, SMS gateway and Bulk SMS solutions, and sign-up for a Developer account on our Tyr SMS Gateway service to try us out.
We provide a wide range of CPaaS services and infrastructure to organisations, including cloud platforms that enable you to run your own SMS gateway.
Get in contact with us to find out more about CPaaS voice, messaging, video and identity from Melrose Labs.
For testing your application's SMS support when using the SMPP protocol, we recommend starting with the Melrose Labs SMSC Simulator service to 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.SMSC Simulator
For live testing and delivery to mobiles, use the reliable and dependable Melrose Labs Tyr SMS Gateway for A2P, P2A, bulk, wholesale and business SMS, text marketing and other uses. The Melrose Labs Tyr SMS Gateway supports REST and SMPP APIs.Tyr SMS Gateway
Alternative APIs and languages
Other APIs covered in our tutorials that can be used for sending and receiving SMS using Perl include: REST
Other languages covered in our tutorials that can be used for sending and receiving SMS with SMPP include: Python, PHP, Java, C++, C#, Go, Node.js, Ruby