Shell
Sample 1 - Account and
Password input in Shell Script
# Assume the smscmd command is under /home/david .
# Text and phone # input from console as $1 and $2
#!/bin/bash
cmd="/home/david/smscmd"
account="registered@sms4mail.com"
pwd="password"
run="$cmd '$1' '$2' '$account' '$pwd' "
eval $run
Shell Sample 2 Call smscmd and use encrypted password file
smscmd.key
# Text and phone # input from console as $1 and $2
#!/bin/bash
cmd="/home/david/smscmd"
run="$cmd '$1' '$2' "
eval $run
Perl Samle1 Call smscmd and use encrypted password file smscmd.key
download
this sample code
#!/usr/bin/perl
#Download smscmd_linux.zip from sms4mail.com/download/linux/smscmd_linux.zip
#Update email and password in sms4mail.txt and run ./smscmd genkey to
encrypt password file to smscmd.key
#Remove password file sms4mail.txt
if ($#ARGV <=0)
{
print "\n smscmd for PERL -- sms4mail.com";
print "\n\n perl smscmd.pl 'text' 'phone1,phone2'";
print "\n\n Download smscmd_linux.zip from sms4mail.com/download/linux/smscmd_linux.zip
first";
print "\n Unzip and update email and password file sms4mail.txt";
print "\n Run smscmd genkey to generate encrypted password file
smscmd.key";
print "\n Remove sms4mail.txt for safety\n\n";
exit(0);
}
my $cmd = "./smscmd " . "'" . $ARGV[0] . "' '" . $ARGV[1] . "'";
system($cmd);
print "SMS sent finished\n";
exit(0);
Perl sample 2
###################################################################################################################
### Usage: perl perlsms.pl "text" "phone1,phone2" "email" "password"
### sample to local # 3478254321 and global +44712335667744 :
### perl perlsms.pl "this is a test" "3478254321,44712335667744" "mymail@mydomain.com" "password"
###################################################################################################################
#!/usr/bin/perl
my $text = $ARGV[0];
my $to = $ARGV[1];
my $email = $ARGV[2];
my $pwd = $ARGV[3];
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $url = "http://www.sms4mail.com/smsmail/php/smscmd.php";
my $req = POST $url, [
Header => 'Content-Type: application/x-www-form-urlencoded',
text => $text,
to => $to,
email => $email,
pwd => $pwd,
];
$resp = $ua->request($req)->as_string;
print "\nResponse back:\n$resp\n";
|
PHP Samle1 Call smscmd and use encrypted password file smscmd.key
download this sample code
<?php
//Download smscmd_linux.zip from sms4mail.com/download/linux/smscmd_linux.zip
//Update email and password in sms4mail.txt and run ./smscmd genkey to
encrypt password file to smscmd.key
//Remove password file sms4mail.txt
if ($argc <=2) //print help
{
print ("\n smscmd for PHP -- sms4mail.com\n");
print ("\n php smscmd.php 'text' 'phone1,phone2'\n");
print ("\n Download smscmd_linux.zip from sms4mail.com/download/linux/smscmd_linux.zip
first");
print ("\n Unzip and update email and password file sms4mail.txt");
print ("\n Run smscmd genkey to generate encrypted password file
smscmd.key");
print ("\n Remove sms4mail.txt for safety\n\n");
exit;
}
$cmd = "./smscmd '$argv[1]' ' $argv[2]'";
$ret = shell_exec($cmd);
echo("$ret");
?>
PHP Sample2
<?php
//// call this sample using POST method . /////////////////////////////////////////////////////////////
$text = $_POST["text"];
$to = $_POST["to"];
$email = $_POST["email"];
$pwd = $_POST["pwd"];
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$url = "http://www.sms4mail.com/smsmail/php/smscmd.php";
$post = array(
"text"=>"$text",
"to" => "$to",
"email"=>"$email",
"pwd"=>"$pwd",
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
// execute
$response = curl_exec($ch);
// close the connection
curl_close($ch);
// print response
echo "$response";
?>
|
Python Samle1 Call smscmd and use encrypted password file smscmd.key
download
this sample code
#!/usr/bin/env python
#coding=utf8
import sys,os
if len(sys.argv) <= 2 or sys.argv[1] == 'help':
print('''\
smscmd for python -- sms4mail.com
python smscmd.py 'text' 'phone1,phone2'
Download smscmd_linux.zip from sms4mail.com/download/linux/smscmd_linux.zip
first
Unzip and update email and password file sms4mail.txt
Run smscmd genkey to generate encrypted password file
smscmd.key
Remove sms4mail.txt for safety
''')
sys.exit(1)
text = sys.argv[1]
to = sys.argv[2]
os.system('./smscmd "' + text + '" "' + to + '"')
print("SMS sent finished")
Python Sample2 Click
here to download Python code and run directly -
Working in
x86 and ARM CPU
###################################################################################################################
### pythonsms.py - Python sample from sms4mail.com.
### Usage: python smscmd.py 'text' 'phone1,phone2' 'email' 'password'
### Sample to local # 3478254321 and global +44712335667744 :
### default non unicode : python smscmd.py 'this is a test' '3478254321,+44712335667744' 'mymail@mydomain.com'
'password'
### for unicode : python smscmd.py 'this is a test' '3478254321,+44712335667744' 'mymail@mydomain.com'
'password' '1'
###################################################################################################################
|