ColdFusion Mail Spool Lock
Recently I've seen posts on both the CF-Talk list at House of Fusion and the Adobe ColdFusion Forum about a lock on the CF Mail Spool. At some point messages in the spool recycle over and over, without processing out to the mail server or going in to the undelivered folder.
I was working for a small regional internet service provider when I began working as a ColdFusion developer. We hosted around six hundred corporate sites, most of which used the <cfmail> tag in some form of form processing or another. This was back in the days of ColdFusion 4.0, and was when I first encountered this issue, and I've seen it several times since.
Basically what happens is the ColdFusion server loses it's connection to the mail server momentarily. Typically you'll see an error in your ColdFusion mail.log file that will state that the connection to your mail server failed at some point. When this happens there is a file lock on a .cfmail file in the spool that was being processed at the time the failure occurred. The connection comes back, but the file lock seems to cause a continual loop on the spool, which disallows the flow of files from the spool to the mail server. It often goes unnoticed until a client calls in to complain that they haven't recieved any leads from their site.
The issue is really easy to get around, but does require you to take down ColdFusion services for a moment so that the file lock is released. Here is a general outline of what you should do.
- Stop ColdFusion services
- Cut and paste all .cfmail files from the spool folder into a temporary folder.
- Restart ColdFusion services
- Verify the mail server connection in the ColdFusion Administrator
- Drag .cfmail files from the temp folder back into the spool folder at about 200 messages at a time, waiting for all messages to process out of the spool before moving to the next batch.
That's it. Pretty easy to handle. Your greatest hurdle is convincing a shared hosting provider that this needs to be done, but if they watch the spool folder and notice the same messages re-enter the spool repeatedly, without dropping to the undelivered folder, then it is a solid indicator that this is what has occured. All files leave the spool and show up five, ten, even fifteen minutes later. I have now worked for two separate hosting companies running everything from ColdFusion 4 through 7, and have seen it occur on each version at one time or another. Hope this helps someone!


in undeliverable folder and not in spool folder.
This method will reset a deadlock you might have on your active spool, but it won't resolve connection issues to your mail server. That's something else altogether, generally relating to errors in DNS, a change of IP address, or just outside networking connection issues in general.
One thing that I noticed that I'm not sure is different than one you came across is that all the .cfmail files that caused the lock were empty. They had a file size of 702 bytes or so, so weren't 0 byte files, but there was no text when you opened up the file. So I had to delete each of those files when I came across a lock.
I was thinking of writing a scheduled job that would check the spool directory each night and look for files older than a day old or so, and send an alert if there were. Except, ColdFusion wouldn't be able to actually send the mail in that case.
Can you think of any other ways that I could search for these old mail files? We had old mail from about 2-3 weeks in the spool folder, and didn't come across the problem until we started getting hard errors from CFMail 3 days ago.
As far as your scheduled task, you might be able to use the SMS gateway to send a text message in the event of a lock. Just an idea...
Yeah, I was being conservative on the side of caution. I think most of the time I could get away with doing them 1,000 at a time. For future use, Andy Matthews, a co-worker of mine also wrote a handy utility that can run as a scheduled task to reprocess your undelivered items, the Undelivrnator:
http://undelivrnator.riaforge.org/
thx for info