Hello all :)

I managed to do some good progress.. :)

1 #!/usr/bin/perl -w 2 use strict; 3 use warnings; 4 use Mail::Header; 5 use LWP::UserAgent; 6 use HTTP::Request; 7 use Email::Simple; 8 9 my @liste = (<>); 10 my $header_object = new Mail::Header \@liste, Modify => 0, MailFro +m => "COERCE" ; 11 12 my $to = $header_object->get('To'); 13 my $username = substr($header_object->get('To'), 0, index +($header_object->get('To'), '@')); 14 my $apparently_from = $header_object->get('Return-Path'); 15 my $from = $header_object->get('From'); 16 my $mail_from = $header_object->get('Mail-From'); 17 my $subject = $header_object->get('Subject'); 18 19 20 21 my $email_details = new Email::Simple; 22 23 my $body = $email_details->get('Body'); 24 25 /* Printing to file - testing */ 26 27 my $filename = '/var/scripts/log/mail2sms.txt'; 28 open(my $fh, '>', $filename) or die "Could not open file '$filenam +e' $!"; 29 30 print $fh ' To: ' . $to; 31 print $fh ' From: ' . $from; 32 print $fh ' maybe From: ' . $apparently_from; 33 print $fh ' Subject: ' . $subject; 34 print $fh ' Username: ' . $username; 35 print $fh ' mbox From: ' . (split(/\s+/,$mail_from))[0]; 36 print $fh ' Body: ' . $body; 37 print $fh $/; 38 39 40 41 my $ua = new LWP::UserAgent; 42 $ua->timeout(120); 43 #my $result = `ps -e | grep -v grep|grep smsbox |awk \'{print \$1} +\'`; 44 #my $result = true; 45 46 #if ( $result ne "" ) 47 { 48 my $url="http://x.x.x.x:14013/cgi-bin/sendsms?username=kanneluser& +password=kannelpassword&to=$username&from=mail2sms&text=$subject $bod +y"; 49 my $request = new HTTP::Request('GET', $url); 50 my $response = $ua->request($request); 51 my $content = $response->content(); 52 }

My Issue is this now, Lines: 21,23 is not working, can someone help me?

also for the body, is it possible to make it as a single string?


In reply to Re^2: mail2sms for Kannel by Pizu
in thread mail2sms for Kannel by Pizu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.