in reply to Handling Incoming Mail

I'm not an expert when it comes to Perl by any means, but I'd personally let the mail go into a mailbox and parse it from there, rather than grab it from STDIN.

Let the mail delivery system worry about getting the messages into the right place, and more importantly, written to the filesystem - so that you've got a chance of recovering some information if something goes wrong (i.e. power outage, OS crash).

Once you're sure that you successfully inserted the information into your database, then you can delete the message from the mail spool.

As far as I can make out, your current setup is

In my head you could let the mailsystem handle the first 2 steps - I'd start by slurping the mailspool into a parser.
Baz.

Replies are listed 'Best First'.
Re: Re: Handling Incoming Mail
by jbert (Priest) on Dec 11, 2001 at 16:42 UTC
    Yep. I second this. You *really* don't want a simple error in your script resulting in lots of bounce messages going back to list admins.

    Of course, what you are describing isn't a million miles away from using procmail/rules on the server to filter different lists into different folders and then using a protocol like IMAP to run queries against the folders to find certain messages. Some IMAP server (Cyrus?) use a database for message storage so you should get better-than-grep performance.

    There a million ways to skin this cat. The tricky bit of the feline is the bit before the mail has been delivered, since errors then will result in lost mail and/or bounces going back (if your MTA considers that it hasn't discharged its duties it feels honour bound to confess to others).