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?