Email2sms~~~

Rangau2

Well-known member
  • Dec 31, 2008
    20,468
    1,211
    113
    34
    දෙණියාය :)

    Attachments

    • 1.JPG
      1.JPG
      29.4 KB · Views: 48

    dumasrc

    Member
    Oct 6, 2009
    3,768
    365
    0
    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


     

    Rangau2

    Well-known member
  • Dec 31, 2008
    20,468
    1,211
    113
    34
    දෙණියාය :)
    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


    machan meka save karanna oni kohomada html or php ?
    a wena data base akak ahema hadanna oni ne neda ?me script aka vitharak athe neda ?
     

    dumasrc

    Member
    Oct 6, 2009
    3,768
    365
    0
    දෙවියනි ඔබ කොහෙද? :eek::eek:

    මචන් මම ඉතින් උදවු කරලා පුරුද්දට ගුගල් එකේ රවුමක් දලා හොයාගත්තේ ඔක නැතුව උබ කියන්න ඉස්සරවෙලා සතේක දෙයක් ඔය සබ් එක ගැන දැනන් උන්නේ නැ:lol::lol::lol: සමාවෙයන් :):)
     

    Rangau2

    Well-known member
  • Dec 31, 2008
    20,468
    1,211
    113
    34
    දෙණියාය :)
    දෙවියනි ඔබ කොහෙද? :eek::eek:

    මචන් මම ඉතින් උදවු කරලා පුරුද්දට ගුගල් එකේ රවුමක් දලා හොයාගත්තේ ඔක නැතුව උබ කියන්න ඉස්සරවෙලා සතේක දෙයක් ඔය සබ් එක ගැන දැනන් උන්නේ නැ:lol::lol::lol: සමාවෙයන් :):)
    oh akath ahemada ok ok mamama hoya gannam ahenam..ath kohomada ??lol ?
     

    Rangau2

    Well-known member
  • Dec 31, 2008
    20,468
    1,211
    113
    34
    දෙණියාය :)
    i have 1 script but no working

    <SCRIPT language=Javascript>
    <!--
    var charLeft = 144;
    /*function newPopup(URL, Name, features) {
    window.open(URL, Name, features);
    }*/

    function checkSend() {
    if (window.document.SMS.tele_no.value ==""){
    alert("Please Enter the SMS number !");
    window.document.SMS.tele_no.focus();
    return (false);
    } else if (window.document.SMS.sendername.value == "") {
    alert("Please compose Your Name !");
    window.document.SMS.sendername.focus();
    return (false);
    } else if (window.document.SMS.txtMsg.value == "") {
    alert("Please compose the message first !");
    window.document.SMS.txtMsg.focus();
    return (false);
    } else {
    checkOk = "+0123456789";
    checkStr = window.document.SMS.tele_no.value;
    allValid = true;
    for (j = 0; j < checkStr.length; j++) {
    ch = checkStr.charAt(j);
    for (k = 0; k < checkOk.length; k++)
    if (ch == checkOk.charAt(k))
    break;
    if (k == checkOk.length) {
    allValid = false;
    break;
    }
    }

    if ((!allValid) || (window.document.SMS.tele_no.value.length != 9)) {
    alert("Please enter a valid receipient's mobile number !\nEg. 711234567");
    window.document.SMS.tele_no.select();
    window.document.SMS.tele_no.focus();
    return (false);
    }
    return (true);
    }
    }

    function countChar() {
    if (window.document.SMS.txtMsg.value != "") {
    strInput = window.document.SMS.txtMsg.value;
    strLength = strInput.length;
    if (strLength > charLeft) {
    window.document.SMS.txtMsg.value = strInput.substring(0, charLeft);
    alert ("Maximum allowed message length exceeded !");
    strLeft = 0;
    } else {
    strLeft = charLeft - strLength;
    }
    if (strLeft < 10) {
    window.document.SMS.txtLeft.value = " " + strLeft + " characters left";
    } else if (strLeft < 100) {
    window.document.SMS.txtLeft.value = " " + strLeft + " characters left";
    } else {
    window.document.SMS.txtLeft.value = " " + strLeft + " characters left";
    }
    }
    }

    function updateCount() {
    if (charLeft < 10) {
    window.document.SMS.txtLeft.value = " " + charLeft + " characters left";
    } else if (charLeft < 100) {
    window.document.SMS.txtLeft.value = " " + charLeft + " characters left";
    } else {
    window.document.SMS.txtLeft.value = " " + charLeft + " characters left";
    }
    }

    //-->
    </SCRIPT>