Move to data-driven decision making with my new NPS survey software.
All my readers receive 10% off for life with code: ian
helpspot update mail integration
October 19, 2004
Now that we've got the general application framework in place, things like authentication, error handling, etc we're moving on to some of the core functionality. The ability to pull messages in from multiple mailboxes is a primary feature of HelpSpot. We have to reliably pull in messages from multiple mailboxes and then have those messages be posted as requests to the general help desk queue or optionally be assigned directly to a particular person. For example, I may have a mailbox called email@example.com. Since I know Phil always answers desktop questions I can avoid having messages in this box go in the general help desk queue and instead assign them immediately to Phil. This has a huge impact on response speeds. Not only does the question get to Phil faster, but it's also one less request the help desk team needs to review and forward.
This sounds fairly easy to do but it gets complicated fast. The mailbox itself might be pop3 or imap, it could be over a secure connection perhaps it's not always available. We need to write code for all these situations. Once a connection is established the fun really begins. Actually working at this low level with email gives me new found respect for dedicated mail applications like Thunderbird and Outlook. There are just so many pitfalls and possibilities to consider. Of primary concern are determining if the message body is HTML or text, are there attachments, if there are attachments what mime type are they, are they nested, are there inline mime objects as well, etc. Whew.
As I mentioned the other day, PHP could use a little more abstraction in this area. The IMAP extension which handles all this stuff works reliably but it still leaves you with alot of code to write to implement these things and since almost everyone working with mail wants to do the same things it would be better done if pushed down into the C library. Anyway, I'll leave you with a sample of the code you would need to pull out email with attachments in ColdFusion: