Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Re: Newbie : Extracting Attchments from E-Mail and storing in a directory

by dada (Chaplain)
on Oct 25, 2002 at 09:25 UTC ( #207937=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Newbie : Extracting Attchments from E-Mail and storing in a directory
in thread Newbie : Extracting Attchments from E-Mail and storing in a directory

ok, we are one step further :-)

what your script is doing is: waiting for something to come on input (STDIN). this means you're supposed to call your script like this:

perl strip.pl < file.msg
supposing that file.msg is a file that contains the mail you are going to process.

cheers,
Aldo

King of Laziness, Wizard of Impatience, Lord of Hubris

  • Comment on Re: Re: Re: Newbie : Extracting Attchments from E-Mail and storing in a directory
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Re: Newbie : Extracting Attchments from E-Mail and storing in a directory
by kev (Initiate) on Oct 25, 2002 at 09:47 UTC
    Okay, I understand that. But what i don't understand is how do I access the mail messages to run this on them? e-mail is sent to me@localhost.localdomain and sendmail is running. typing mail at the command prompt (or whatever the Linux version is called) says I have n messages. (where n is a number) Also I read someware else that you can create a `.forward` file in the root of your home directory to automate this. (the desired operation as there will be a dedicated e-mail server for this - currently being tested on a standalone laptop)
    "|IFS=' '&&exec perl /home/kev/Documents/webtest/mail/strip.pl||exit 7 +5"
    (modified from another one) This just loses the mail (Evolution or mail can't find it). I'm guessing I would probably need to change this to something along the lines of
    "|IFS=' '&&exec perl /home/kev/Documents/webtest/mail/strip.pl < file. +msg ||exit 75"
    Is this along the right lines?, and what would i need to put in the place of "file.msg"?
      I've now worked out that to call the perl file i need to use the line
      "| /home/me/Documents/webtest/mail/strip.pl < $1"
      in the `.forward` file. I have also found the missing e-mails - they were in the root mail box. in the mail i have
      --- The Following addresses had permanet fatal errors ---- "| /home/me/Documents/webtest/mail/strip.pl < $1" (reason : service unavailble) (expanded from : <me@localhost.localdomain>) ---- Transcript of session follows ---- 451 4.0.0 hash map "generics": missing map file /etc/mail/genericstabl +e.db: No such file or directory smrsh : strip.pl not avalible for sendmail programs 554 5.0.0 Servive Unavalible [Snip message headers, body and attachments]
      How do i create "genericstable.db" and allow strip.pl to be avalible for sendmail programs?
        You are almost there. The line in .forward that is | /home/me/Documents/webtest/mail/strip.pl < $1 means that the script already gets its input from STDIN, so the redirection part is unnecessary. Change it to : | /home/me/Documents/webtest/mail/strip.pl and everything should work, or at least, this error should be eliminated. The error in the mail to root meant that the "recipient" /home/me/Documents/webtest/mail/strip.pl > $1(almost your script) had errors. This means that either your script did not compile properly (make sure you check this every time you modify the script!!!!) or that sendmail could not start it with the redirection (I guess the error in this case).
        A good idea is to dry-run a check against your script every night with some known good input so the mail does not get silently discarded. I do this with my home-made spamfilter (maybe soon to be replaced with a serious solution).
        perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
        I've now got the script working manually (it probably did most of the time, i just never tried it. I used evolution and saved as an .eml but as for automating it i'm at a complete loss, anybody got any ideas? It seams that sendmail can't execute perl scripts from what i gather in the failed to deliver messages.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2022-05-25 04:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (84 votes). Check out past polls.

    Notices?