I need a custom script that will run via a cron job...
Please note that I have a mySQL database, accessible via PHP scripting, that supports multiple users. Each user must enter a username and password to log in. Once logged in, each user then has access to her/his own personal records. This is already set up and in place. Regarding the mySQL database, a simple table called "Messages" has been set up with the following fields: A Primary Key field, a Subject field, a Message field, and a Date field.
Next, I have a single POP e-mail account set up for the multiple users. I need a PHP script that will run regularly (via a cron job). I need the script to check the POP e-mail account regularly and filter/identify messages for each individual user and then add each user's e-mail message(s) directly into the Messages table of the mySQL database.
For example, suppose I have two users set up: Bob100 and Mike200. Bob100 and Mike200 each write an e-mail (from their personal e-mail accounts) and then send the messages to the multiple-user POP e-mail account on my server. On the first line of Bob100's e-mail he includes his user ID within double brackets: [[Bob100]]. On the first line of Mike200's e-mail he includes his user ID within double brackets: [[Mike200]].
Via the cron job, the script checks the multiple-user POP e-mail account and searches the body of each message for user IDs (within double brackets). In the examples above, messages containing [[Bob100]] and [[Mike200]] are found. These usernames are then parsed, and then the mySQL database is searched to see if the users exist. If so, then the Subject and Body of each applicable e-mail message is then parsed and inserted within the Messages table. Again, when logged on, each user will only be able to see her/his own messages.