Send an SMS Using Perl

The TextMagic API Perl wrapper can save you a lot of time, as it includes all the necessary API commands and tests. It only takes a few seconds to download it from GitHub and to install it into your own app or software. After installation, you'll then be able to send text messages.

Get it now on GitHub
Perl logo

Installation Instructions

  1. Download the latest version of the wrapper from GitHub.
  2. Run the following commands:
    • perl
    • make
    • make install
  3. use Net::SMS::TextmagicRest in your code.


The Perl wrapper for TextMagic API has the following requirements:

  • Perl 5.6 or higher
  • Rest::Client
  • JSON
  • Carp
  • String::CamelCase
  • Test::MockModule (for running tests only; however, you could use the wrapper without that dependency)

Sending an SMS using Perl (an example)

Below is an example of how to send a text message using Perl.

use Net::SMS::TextmagicRest;

# Ask user for numeric input
sub readNumber {
    my $text = shift;

    print "$text: ";
    my $choice = <STDIN>;
    chomp $choice;

    $choice =~ s/^\s+|\s+$//g;

    return $choice;

my $tm = Net::SMS::TextmagicRest->new(
    username => "test",
    token    => "my-api-key",
print "Enter SMS text: ";
chomp(my $sendingText = <STDIN>);
print "\n\nEnter phone numbers, separated by [ENTER].\n";

my @sendingPhones = ();
my $phone;
do {
    $phone = readNumber('Phone');
    push(@sendingPhones, $phone)
} until (!$phone);

my $result = $tm->send(
    text    => $sendingText,
    phones  => \@sendingPhones,
print "Message session $result->{id} successfully sent\n";


If you need help with the wrapper, or if you have any suggestions for improvements and/or if you have any enquiries regarding the Perl SMS API, please contact us by emailing  .