use Mail::Address; use Getopt::Long; use MOJO::Config; # configuration variables use MOJO::Mail::Send; # use the MOJO::Mail::Send module +to send e-mails with use MOJO::App::Guts; # use MOJO::Guts for misc subroutin +es use MOJO::MailingList::Subscribers; use strict; # get header, footer my $header; my $body; { local $/ = ""; $header = <STDIN>; undef $/; $body = <STDIN>; } my $test = 0; GetOptions("test" => \$test); #create a MOJO::Mail::Send object my $mh = MOJO::Mail::Send->new(); #get headers in name=>value pair my %mail_headers = $mh->return_headers($header); # 'normalize' the headers %mail_headers = $mh->clean_headers(%mail_headers); # extract 'To:' addresses my @To_addresses = Mail::Address->parse($mail_headers{To}); # extract anything in the CC: header my @Cc_addresses = Mail::Address->parse($mail_headers{Cc}); # plop them together @To_addresses = (@To_addresses, @Cc_addresses); # extract the 'From:' address my $From_address = (Mail::Address->parse($mail_headers{From}))[0]; my $from_to_check = 0; foreach my $this_address(@To_addresses){ my $from_test = $From_address->address; if($this_address->address =~ /$from_test/i){ $from_to_check = 1; last; } } if($from_to_check == 1){ warn("$PROGRAM_NAME $VER ERROR, quitting script to stop possible i +nfinite loop!"); exit; } # at this point is where I need the vars to post. Make sense? Obviousl +y, we would not need to use all of the above modules/libraries # the mojo script goes on and on to process emails as it would, but we + wish to avoid that so here we would execute the lines mentioned by R +oger. # build variables to pass to PHP via post my %vars = ( var1 => $var1, # the email vars would be here I believe? var2 => $var2, # ... ); # then we would do the post thing # send the POST to php my $url = "http://domain.com/test.php"; my $req = new HTTP::Request; my $res = $us->post($url, \%vars);


The current set up is that the command line email alias forwards the message test@domain.com to this script. This script is then usually used to operate a perl mailing list discussion pacakge called mojo mail. I wish to simply use it to parse the email and move the vars on to php.

Thanks, Nathan

In reply to Re: question about forwarding variables to php from perl by nathan0601
in thread question about forwarding variables to php from perl by nathan0601

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.