Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6391633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:43:01+00:00 2026-05-25T03:43:01+00:00

I found a perl script that checks an email account and forwards the contents

  • 0

I found a perl script that checks an email account and forwards the contents to a gsm phone. It uses below code to determine the body of the email. This can be different for each email package so doesn’t really work. I was going to have a # at the beginning of the email body instead, how would go about doing this?

  sub ProcessEmail
 {
   # Assign parameter to a local variable
   my (@lines) = @_;
   my $body_start = 'FALSE';
   $sms_body = "";

   # Declare local variables
   my ($from, $line, $sms_to);

   # Check each line in the header
   foreach $line (@lines)
   {
 print $line;
     if($line =~ m/^From: (.*)/)
     {
        # We found the "From" field, so let's get what we need
        $from = $1;
        $from =~ s/"|<.*>//g;
        $from = substr($from, 0, 39);               # This gives us the 'From' Name
    }
    elsif( $line =~ m/^Subject: (.*)/)
    {
        # We found the "Subject" field. This contains the No to send the SMS to.

       $sms_to   = $1;
        $sms_to = substr($sms_to, 0, 29);

       if ($sms_to =~ /^[+]?\d+$/ )             # here we check if the subject is a no. If so we proceed.
       {
           print "Got email. Subject is a number. Processing further\n";
       }
   else #Otherwise we delete the message and ignore it.
       {
        print "Got email. Subject is NOT a number. Ignoring it. \n";
        return;
      }
     } 
   elsif(( $line =~ m/^Envelope-To:/)||($body_start eq 'TRUE')) # This is the last line in the email header
    {          # after this the body starts
   if($body_start ne 'FALSE')
   {
   $sms_body = $sms_body . $line;
   }
       $body_start='TRUE';
    }
   }

   # At this point we know the Subject, From and Body.
   # So we can send the SMS out to the provided no.

   $sms_body = "SMS via Email2SMS from $from: " . $sms_body;

   # You can only send SMS in chunks of 160 chars Max according to gnokii. 
   # so breaking the body into chunks of 160 and sending them 1 at a time.
 print  $sms_to;
 print $sms_body;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:43:02+00:00Added an answer on May 25, 2026 at 3:43 am

    Altered to search for a string that was specific to the mailer. Nasty and will only work from a specific mail sender, but it worked

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found a perl script that manages randomizing the wikipedia articles in Wikipedia here
I have a Perl script that uses Selenium to fetch a HTML document called
I've found a Perl regexp that can check if a string is UTF-8 (the
I'm reading Programming Perl , and I found this code snippet: sub new {
I'm running a command line application from within the perl script(using system()) that sometimes
I found this Perl script while migrating my SQLite database to mysql I was
I have a Perl script to convert the XML file below into a hash:
I've an annoying ASP.NET problem: I have a Perl script (see below), which gets
I have a Perl script that monitors any SNMP enabled service. The way it
I found this perl script here which seems will work for my purposes. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.