m242 / maildrop

MailDrop is an open-source, scalable, high-performance version of Mailinator.
Other
725 stars 76 forks source link

JavaMail error preventing Maildrop from working with any "multipart/*" mime types #12

Open charlescapps opened 9 years ago

charlescapps commented 9 years ago

I ran into this error:

no object DCH for MIME type multipart/mixed;

when MailDropMessageHandler called "saveMessage()".

There are discussions about this problem throughout the Internet, e.g. Stack overflow discussion.

In case it matters, I built the smtp module with these very simple steps:


cd smtp
activator assembly
cp target/scala-2.10/smtp-assembly-2.0.jar .
# Use a custom application.conf, which just modified the number of emails per inbox.
java -jar smtp-assembly-2.0.jar -Dconfig.file=application.conf  

I'm using Java 8 (the error still happens with Java 7) and Scala 2.10.

I'd be grateful if the developer could:

I ended up adding this code to fix the issue at the top of MailDropMessageHandler:


        val mc = CommandMap.getDefaultCommandMap.asInstanceOf[MailcapCommandMap]
        mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html")
        mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml")
        mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain")
        mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed")
        mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822")
        CommandMap.setDefaultCommandMap(mc)