Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Simple .forward email parse

by docster (Novice)
on Sep 16, 2008 at 16:29 UTC ( [id://711735]=perlquestion: print w/replies, xml ) Need Help??

docster has asked for the wisdom of the Perl Monks concerning the following question:

Hello friends. I need to take a .forward email to a perl script and extract the "sender address" and "subject". After quite a bit of searching my head is starting to smoke... There seems to be a trillion ways to approach this. But none of the ones I have tried have actually worked. Something I thought was very simple has grown very complicated. ;)

I have the email forwarding to a Perl script. Now I just need to tell "who" sent it. And what the subject line was... Then I can work out the rest of what I need to do. Has anyone done this and can maybe supply me a simple example? Thank you!

Replies are listed 'Best First'.
Re: Simple .forward email parse
by rhesa (Vicar) on Sep 16, 2008 at 16:38 UTC
    Email::Filter rocks!
    my $mail = Email::Filter->new; say "sent by: ", $mail->from; say "about: ", $mail->subject;
      Thank you both. It appears that Email::Filter has replaced Email::Audit. So I tried it and the following works! Thank you.
      #!/usr/bin/perl use Email::Filter; my $mail = Email::Filter->new; my $myFrom = $mail->from; my $mySubject = $mail->subject; exec "echo \"From: $myFrom \nSubject: $mySubject\" > temp.log";

        Unless Email::Filter is making the results taint-safe, you are passing unvalidated data directly to a shell. Big time security no-no. It is better to open the file from within perl, and write escaped data to the file.

        Depending on your mailer, you could also have a race condition on temp.log. Might be better to lock that file prior to writing to it.

        --MidLifeXis

Re: Simple .forward email parse
by Fletch (Bishop) on Sep 16, 2008 at 16:32 UTC

    Should be trivial to whip up something to do this using Mail::Audit.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://711735]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-20 16:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found