Hi There,
Here you Go,
#!/usr/bin/perl
# Scipt: email2sms.pl
# Author: Lee Engel, [EMAIL PROTECTED]
# Date: 14-03-2006
use Email::Simple;
use Net::SMS::Clickatell;
my $logfile = "/usr/local/smsc/incoming.log"; # The log file
my $raw_mail;
my %headers = ();
my $API_CODE = '123456'; # You'll get this when you
sign up
my $URL = ''; # If you wanna send it
somewhere else...
my $USERNAME = 'easitext'; # Your Clickatell username
my $PASSWORD = 'very_secret_password'; # ...and the password
while(<>){ $raw_mail .= $_; } # Put the entire mail
into a variable
my $mailobj = Email::Simple->new($raw_mail);
$headers{Subject} = $mailobj->header("Subject"); # Get the number
from the subject line
$headers{From} = $mailobj->header("From"); # Get the senders
address for logging
$headers{Subject} =~ s/[^\d]//g; # Strip away non-digits
$headers{Subject} =~ s/\s//g; # Strip away whitespace
if($headers{Subject} =~ /^0(8|7)(2|3|4|6|9)/){ # Check if
it's a SA cell number
$headers{Subject} =~ s/^0/27/; # and prepend the 27
to the front
}
if($headers{Subject} eq ''){
die "Subject line is empty. Exiting!\n"; # You might wanna
call it quits if there is no number
}
my $msg = $mailobj->body(); # Put the body into a
variable
$msg = substr($msg, 0, 160); # Just grab the first
160 characters
# Here follows all the Clickatell API stuff.
# Don't worry about this too much, you can read about it at
www.clickatell.com
my $catell = Net::SMS::Clickatell->new( API_ID => $API_CODE, UseSSL =>
0, BaseURL => $URL );
$catell->auth( USER => $USERNAME, PASSWD => $PASSWORD );
$catell->sendmsg( TO => $headers{Subject} , MSG => $msg);
if(my $error = $catell->error){
if($error == 1) {
die("Clickatell Username or password not defined\n");
}elsif($error == 2) {
die("Clickatell Username or password invalid\n");
} else {
die("Clickatell: Unexpected fault\n");
}
}
# Keep a log, you may need it later.
open(FH,">>$logfile") || die "ERROR: $!\n";
print FH $headers{From} . ' ' . $headers{Subject} . ' ' . $msg . "\n";
close(FH);
Cheers
~uppal
p.s. got it from the way back machine at archive.org
Alvaro Cornejo wrote:
Hi
Does anyone has this script ? and some instructions on how to use it?
I've been googling arround and it is not available anymore on the web
www.easitext.com in not longer available... as far as I could found
... well NOT found ;-)
Regards
Alvaro