3

I'm building a coldFusion application that needs to pop mail from a server. The pop code is really basic.

<cfscript>
    variables.mailService = new pop();

    variables.mailService.setAttributes(
        Server = '[my mail server]',
        Username = '[my username]',
        Password = '[my password]'
    );

    variables.Headers = variables.mailService.getHeaderOnly();
    writeDump(variables.Headers);

    variables.Mail = variables.mailService.getAll();
    writeDump(variables.Mail);
</cfscript>

However, when I execute this script after sending an email with a photo attachment, I receive the following error.

The cause of this exception was: java.lang.ClassCastException: 
javax.mail.internet.MimeMessage cannot be cast to 
javax.mail.internet.MimeBodyPart.

Furthermore, not all attachments are having problems. For example, if I mail an attachment from my phone, it works just fine. The problem seems to be limited to when an attachment is inserted inline into the email through Apple Mail. It's been pretty easy to reproduce. I simply drag and drop any JPG file into an Apple Mail message and the retrieval from my CF script fails.

So far I've tried it with a multitude of different mail applications (Gmail, Thunderbird, Outlook, other web based, etc) and I've replaced the JRE that the CF Server is running on (you know, just in case.)

Anyone run into this before or have a workaround?

David Byers
  • 386
  • 2
  • 4
  • 20
  • 1
    Sounds like a bug in the way ColdFusion is using the JavaMail APIs to access the content of the mail message. The MIME standard for mail messages allows a very wide range of possibilities but most mail clients only support a small subset of the possibilities. I've seen cases recently where Apple Mail has created messages that conform to the MIME standard but otherwise have an "unusual" structure. JavaMail can handle all the possibilities, but that unusual structure is probably something that ColdFusion is not prepared to deal with. – Bill Shannon Sep 23 '15 at 03:57
  • Looks like you filed a bug report. If you have any luck with the workaround [suggested on the other bug report](https://bugbase.adobe.com/index.cfm?event=bug&id=4016861), ie using POPCFC (http://popcfc.riaforge.org/), feel free to post an answer for the next guy. – Leigh Sep 28 '15 at 16:49
  • Yeah, I'm actively engaging Adobe on the issue. This is a repeat of a bug that has been reported before, but I'm trying to get them to give it some focus. Regardless, I'll post whatever solution presents itself. – David Byers Sep 29 '15 at 17:14

0 Answers0