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

Forgive me if this question is compleately off the wall, but is there a way to let a Perl script actually look at my email. This is to say acsess my acount and search for mail with a specific subject, and then perform whatever action I might want once that mail has been found? Thank You.

Replies are listed 'Best First'.
Re: Letting a script play with my email?
by ZZamboni (Curate) on Jul 07, 2000 at 20:51 UTC
    This is a very generic question, much more detail would be needed to give a specific answer.

    Certainly you can have a Perl program examine your email. But it depends on many things, like:

    • Where and how is your email stored? In a local mail spool? On a remote POP or IMAP server?
    • When and how you want the Perl program to execute. When each individual message arives? Periodically, processing all the pending messages in batch?
    • What is it that you want to do with each message. Rewrite it in some form? Write results to other files? Execute commands?
    As you can see, there are many unknowns in your question. Almost everything is possible with Perl, but you will have to be more specific if you want more detailed help.

    --ZZamboni

Re: Letting a script play with my email?
by Ovid (Cardinal) on Jul 07, 2000 at 21:00 UTC
    You may be pleased to know that perl.com has an article detailing this very subject. Enjoy!
Re: Letting a script play with my email?
by Shendal (Hermit) on Jul 07, 2000 at 20:46 UTC
    You probably want something like Net::POP3 or Net::SMTP (depending on if your server is a POP3 server or an SMTP server). Use it to retreive your message headers and do whatever it is you want to do with your email.

    Hope that helps,
    Shendal

    Update: As pointed out by le in reply below, SMTP is send only, of course. I wanted to say Net::IMAP -- sorry for the confusion.
      You can't use Net::SMTP to get mail. SMTP is used for sending mail. Retrieving is done via either POP or IMAP.
Re: Letting a script play with my email?
by davorg (Chancellor) on Jul 07, 2000 at 22:22 UTC

    As others have pointed out, this is a very generic question and therefore difficult to answer accurately.

    One idea might be to take a look at David Wood's book Programming Internet Email (O'Reilly). It gives a good overview of the various techniques for handling email and (unsuprisingly) most of the code examples are in Perl.

    --
    <http://www.dave.org.uk>

    European Perl Conference - Sept 22/24 2000, ICA, London
    <http://www.yapc.org/Europe/>