My Projects
Search Blog

Categories
Archives
Useful Links
Photo Albums
RSS

Powered by
BlogCFM v1.15

Vivio Technologies Dedicated Hosting
06 December 2006
ImapCFC Update

CFOpenMail / ImapCFC project page

Every time I made a change to the code in imap.cfc, I had to reinitialize it and log in again.  I had to do this because the init() method stored the connection information in the variables scope of the CFC.. so reloading the CFC would wipe them out.  That got old really fast, so I moved the connection information into the session scope.  Now during development, the CFC can be reloaded on every page call if I want.. but I'll probably just add a "refresh CFC" shortcut into CFOpenMail to ccause that to occur so it only happens when I want it to.

I updated the delete() method to allow the deletion of multiple messages.  I also adjusted the getfolderinfo() and getfolderstructure() methods so they return more information, and don't attempt to get information like message counts and unread message counts on folders that can't actually hold messages.

The copyMessages() method now throws meaningful errors for things like "The destination folder does not exist" and "The destination folder cannot contain messages".

Also, the getMessage() method will throw a meaningful message when you attempt to retrieve an invalid message number.  "The specified message number was not found in the specified folder." instead of what was essentially an "Array index out of bounds" error.

Posted by rickroot at 3:50 PM | Link | 0 comments
05 December 2006
ImapCFC Update

CFOpenMail / ImapCFC project page

I corrected the issue with the folderDelete() method.  It's very strange the way the actual delete method works in the java folder object.  It nearly always returns true, even if the delete fails.  The correct way to determine if the delete was successful is to run the exists() method on the folder you just deleted.  Sometimes, I think OO programming is a little wacky.  Or maybe it's just this particular implementation.

I also implemented the copyMessages() method in CFOpenMail.  I haven't tested it thorougly, but it does work.

The CFC on the project page has been updated to include today's changes.

Posted by rickroot at 4:02 PM | Link | 0 comments
04 December 2006
ImapCFC Update

CFOpenMail / ImapCFC project page

I corrected a bug in the folderRename() method involving mismatched variable names (obj_Folder and objFolder).  However, the method still doesn't work.  Maybe my imap server doesn't allow renaming of folders.  It says it's working, but it's just not renaming the folder.  No errors, and it returns true.

I also added a recurse option to the folderDelete() method that should prevent you from deleting a non-empty folder unless you specify to do the delete recursively.  This too, doesn't work.  Might be time to drop a line to the JavaMail-INTEREST mailing list.

Posted by rickroot at 3:58 PM | Link | 0 comments
01 December 2006
Imap.CFC Update

CFOpenMail / ImapCFC project page

Earlier this week, I decided it would be fun to build a webmail application.  Of course, any good webmail application connects to an IMAP mail server, so I needed to figure out how to use imap in Coldfusion.

Although Bluedragon has a CFIMAP tag, Coldfusion (currently) does not.  I wanted to go open source, and didn't want to require any DLL installations or anything so most of the custom tag options out there were not options (like CFX_IMAP, CFX_IMAP4, etc).  But I did find a project on sourceforge called cfimap-cfc.  Sweet.

I started cranking away, and I've made a LOT of changes to imap.cfc, enhancing its functionality, fixing bugs, etc.  Some of the major changes so far:

  • an authenticated imap session can be stored in memory (the session scope), so you don't have to authenticate every time you try to do something.  This was a HUGE performance increase.
  • the "view" method was incompatible with multipart mime messages with parts whose content type was multipart/*.  In otherwise, a message might have two parts, but one of those parts might also have multiple parts as well.  Curiously, the old imap.cfc worked with such messages but only grabbed the first subpart in such situations.  This required taking part of the view() method out and putting it into a separate method called getParts(), which calls itself recursively for multipart parts.
  • I've properly var scoped *EVERYTHING*.  Version 1.0 of imap.cfc was not var scoped at all, and you could have easily experienced all kinds of variable problems.
  • The old imap.cfc attempted to put HTML and text attachments inline.  Personally, in a web based application, I'd just rather see them as attachments, and so that's what it does now.
  • The download method was enhanced by adding an includeData argument, which, when false, causes the returned structure to not include the actual binary file contents.  The method also now returns file size as well, so you can publish the list of attachments along with their content type and size.
  • Added a slew of try/catch statements because some folders can't contain messages, so you can't open them.  I don't really know why for sure, but I've got one such folder in my Sent folder, so I added error trapping.
  • I also added code hints, changed some variable names and column names, and did some commenting of the code too.

It's worth mentioning that I've never worked with the JavaMail API before, so this was fun and challenging.

There's still a lot of work to do, particularly with regards to the send() feature.  I also haven't yet  tested the deleting, creating, or renaming of folders, nor have I tested the copyMessages() method either.

 

Posted by rickroot at 10:36 PM | Link | 4 comments
26 April 2006
Coldfusion and qmail-inject

If you're running a coldfusion server on a unix system with qmail installed, then maybe you, like me, have often wished you could just directly pump email into the qmail queue.

If that's you, read on!

Posted by rickroot at 11:55 AM | Link | 0 comments