Group email forwarding

We have a small members group with our own web site and want to set up a system that allows any member to send an email to our group email address, and once an hour (for example) a cron job to run which:

  1. Checks the mailbox
  2. Looks to see if any new (un-forwarded) messages are there
  3. If new message(s), goes to members db, checks if message from member, if ‘no’ delete message, if ‘yes’ then send each member a copy.
  4. Marks message(s) sent/forwarded

I can see how to do this if I set up a members page form that submits to a db, and then I query the db, but not if the message comes in by email.

I’ve been looking at phplist but it seems that it only allows the admin to create the source email, so I’d appreciate any pointers on how, under *nix to use PHP to read a POP3 (or IMAP) mailbox and read the contents then marking messages as sent/deleted etc. I can then handle the cron job/mailto() etc.

Thank you.