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

I've done a search on your site for parsing email and similar information and have read literally hundreds of excellent replies. My question isn't quite like the others, tho. Here's what I'd like to accomplish:

1) An automated system (nearly real-time) that parses email (from one source only), finds info (next to a particular keyword), appends it to a flat/text database, generates a random, unique password & also appends it, emails the parsed text 2 places.

The nearly real-time aspect of checking for new mail could be able to be done using Crontab (I think). Just set it to run the routine once per minute.

However, these would appear to be the real problem(s):

2) The system should monitor on an hourly basis to see how long, in days and hours, since the original email in (1) had been sent.

(3) Detect how many times any given individual has visited the site that the Perl script is running on.

Whew! I know that it's a pretty tall order but I'd really apreciate any info/code you can give me.

Thanks in advance, Kent

Replies are listed 'Best First'.
Re: Newbie: Parsing Email
by Eimi Metamorphoumai (Deacon) on Jan 06, 2005 at 19:38 UTC
    I'm afraid you haven't made yourself very clear about how these things are put together. Specifically, it sounds like 2) and 3) are completely separate scripts from the first one. That said, I would like to mention that, depending on your host and what sorts of access you have, procmail might be a very simple way to make sure your perl script is called once for each mail as it comes in. Much simpler than polling a mailbox.

    Beyond that, I'm afraid you'll have to post more about exactly what problems you're running into. Consider breaking the problem into smaller pieces and explaining what you're doing with each of them.

Re: Newbie: Parsing Email
by qq (Hermit) on Jan 06, 2005 at 20:49 UTC

    As noted, you'll need to cut your problem down. You've begun to do so, but its still quite vague. In particular it's not clear what the random/unique password is for, and its not at all clear how you'll tell how many times a user has visited the site. Are they logging in with that generated password? Its not really possible to count visits unless they are.

    Finally, try and think about the application requirements distinctly from the technical requirements. (But do post what technical solutions you've started on, or the monks will think you are slacking.;) )

Re: Newbie: Parsing Email
by Limbic~Region (Chancellor) on Jan 07, 2005 at 15:39 UTC
    CKent,
    After clearly defining your requirements, you might want to investigate if there are any low cost products that already meet your needs. That said....

    I would use Mail::Audit. Presumably, your MTA can deliver emails to a program and not to a mailbox. This would alleviate the need for a cron. You can use the body method to parse for your desired info. You can use your database of choice (MySQL, PostgreSQL, DBD::SQLite, etc) to store/retrieve your information. Next, you can use the reply method to send the desired response back. Finally, you can use the resend method to send the email to a real mailbox for long term storage.

    As far as parts 2 and 3, these are separate scripts that interact with the database in part 1. The second one can be done with a cron job that determines the difference between the create timestamp stored in the database and the current timestamp. The 3rd one can be done by incrementing a column in the database each time someone logs in.

    Of course there are lot's of issues such as session management, properly handling locking to avoid DoS attacks, etc. When you are beyond this general description and down in the weeds, come back and ask specific advice and we will be here waiting.

    Cheers - L~R

Re: Newbie: Parsing Email
by CKent (Initiate) on Jan 15, 2005 at 00:57 UTC
    Not sure that I'm doing this right, but will find out soon enuf.

    Eimi Metamorphoumai and qq, yes, upon reflection these are completely separate tasks. Have been looking into individual snippets to get this going.

    Also, yes, the password is for access to a particular page on the site.

    Limbic~Region, Thanks for the individual building blocks that will help me get this job done. I've done some googling & have found some really good code.

    Anyway, thanks to all you monks. When it gets rolling I'll send you a link to see what it's all about.

    Kent