Search code examples
phpemailpipepop3procmail

POP3 email to MySQL database? What options do I have?


Ok..... basically what I'm trying to do is setup something that will handle all incoming mail on a certain POP3 email address, pass all the relevant data to a PHP script, which will then parse the data & insert it into a MySQL database.

Now I have been looking around a bit..... checked out procmail, but that just confused the hell outta me (I'm not much of a server guy, just know enough CL stuff to get by), so was wondering if there were any better options available to me or any existing PHP classes that made it a bit easier?

Thanks a lot - any help would be much appreciated!


Solution

  • Sounds like you have two tasks before you:

    1. Write a PHP script that checks the POP3 account, processing any mail it finds.--You could use PHP's IMAP functionality, which supports IMAP, POP3 and NNTP.

    2. Somehow get the above-mentioned script to run when new mail is received.--An easy way to simulate this effect would be to use a cron task to run your script regularly...perhaps every few minutes. Hopefully, your web host supports cron tasks--you may find an option to set them up in your hosting account's control panel or you may need to contact support for assistance.

    Hope this helps,
    Ben