I need a system to log certain e-mail messages so that they can be displayed online as well. I would like this to be as simple as possible, so wanted to ask if someone know of an existing solution before I start to build this myself. I am also interested an any information that could help me build this tool, if a solution doesn’t already exist.
Ideally I would just like to set up an e-mail address, say for example log-me@mydomain.com, that would be used only for this purpose, so there doesn’t need to be any complex sorting/parsing of WHAT messages to store, it would be safe to assume that any messages received at that e-mail address should be logged. I will perform admin/moderator functions after the messages have been added to the database. I want to be able to write an e-mail, copy the log-me@mydomain.com address in the CC/BCC field, and have the system log the e-mail when it’s received. I also have no problem scheduling the process to run at specific intervals, I use several scripts like this already.
So, thinking about it, if there isn’t a system for this type of thing already, and I need to build it myself, all I really need is a way to get e-mail via pop3 to a mysql database, preferably keeping any html formatting the e-mail may contain, the rest of it I already know how to do.
I did search online for a solution and didn’t have much luck, so any help would be greatly appreciated.
So I ended up finding this Email to DB: http://www.phpclasses.org/discuss/package/3324/
It works exactly like what I was looking for, and I can now do what I need with the info once stored in the DB.
There is a small bug in the package though. The ‘from’ address shows up as the ‘from’ and ‘to’ address in the DB. Here’s the code that needs to be changed in the class:
That $from on line 9 on my code above, should be changed to $to. That will fix the bug and display the correct ‘to’ address in the DB. The class is in one file, so just search for:
to find the code that I posted above.