How do I receive email and process it in a web application

I recently worked on a project that required parsing of email from gmail and updating database with certain values based on the contents of the email. I used the ezcMail (now) Zeta Components library to connect to the mail server and parse the emails.

The strategy I adopted was to filter all interesting incoming mail with a label “unprocessed”. Run the PHP script via a crontab every 15 minutes. The script would connect to the mail server and open the IMAP unprocessed folder and parse each email. After inserting the interesting values into the database, the script moves the files to another IMAP folder “Proccessed”.

I also found IMAP to be better than POP for this sort of processing.

Leave a Comment