I’m trying to implement a mail parsing feature on a Codeigniter site. This is my first attempt at something like this.
I would like users to be able to send emails to newevents@mysite.com, and then set up a cron job to check the mailbox at intervals, parse the emails for a unified format, and then update SQL.
Something like
EMAIL FROM john@gmail.com
((eventname:My upcoming event))
((description:You must come. There will be women of loose moral fiber. And cheetos.))
((date:2013/04/13))
Similar to what you can do with many online “Todo” sites. I would check the “from” address against the DB, and then INSERT the data.
I’m a bit confused because I see that PHP has an IMAP/POP3 class that seems pretty complex, but I have also found a code example that seems completely basic.
$php = connect ("mymailserver.com", $port = 110);
$login= login("email","test", $php);
$firstmsg= get(0, $php);
message_details($firstmsg, 0, $php);
quit($php);
Apparently this should grab the unread messages, and I see that I can grab them all and put them in an array for processing. I imagine that they would then be marked “read”. But why are the other solutions so much more complex? It leads me to believe that this is too good to be true.
Am I not understanding something?
That code does not use predefined PHP functions. You will need to either use the PHP POP / IMAP classes for which you found documentation on php.net, or a library that someone else wrote.