glassfish
  1. glassfish
  2. GLASSFISH-20772

GlassFish JavaMail alters Content-Disposition of MIME Parts on MultiPart message with inlined jpeg image

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 4.0_b89_RC5
    • Fix Version/s: None
    • Component/s: mail
    • Labels:
      None
    • Environment:

      Any

      Description

      When sending an email with an inlined jpeg image using a multipart MIME message with the image being a MIME part declared with:
      Content-Disposition: inline;

      and referenced via cid.

      GlassFish converts the mime part from being 'inline' to being 'attachment':

      Content-Disposition: attachment;

      And hence the image is not embedded on the email. Same test case sent via JavaSE happens correctly.

      This doesn't happen for png images. inlined png images are preserved as inlined

        Activity

        Hide
        Bill Shannon added a comment -

        I'm sure GlassFish isn't changing the message. What evidence do you have that it is?

        Are you using the same mail server for both the GlassFish test and the Java SE test?

        Turn on JavaMail Session debugging by using session.setDebug(true) and the server log file will show you exactly what JavaMail is sending.

        Show
        Bill Shannon added a comment - I'm sure GlassFish isn't changing the message. What evidence do you have that it is? Are you using the same mail server for both the GlassFish test and the Java SE test? Turn on JavaMail Session debugging by using session.setDebug(true) and the server log file will show you exactly what JavaMail is sending.
        Hide
        pranahata added a comment -

        Hey Bill,

        I deliberately made a provocative subject line to try to get attention as soon as possible. But there is something going on with the javamail implementation bundled in glassfish.

        The only difference i can see in both environments is the mailcap file in the METAINF of java.mail-1.5.0.jar

        The one in glassfish has the following two lines commented:

        #

        1. can't support image types because java.awt.Toolkit doesn't work on servers
          #
          #image/gif;; x-java-content-handler=com.sun.mail.handlers.image_gif
          #image/jpeg;; x-java-content-handler=com.sun.mail.handlers.image_jpeg

        I think when running on SE, there is a mailcap file in the JRE installation dir that has those two lines enabled.

        If i do:

        MailcapCommandMap mailcap = (MailcapCommandMap)CommandMap.getDefaultCommandMap();
        String[] mimeTypes = mailcap.getMimeTypes();
        log.debug("mailCap types are {}", Arrays.asList(mimeTypes));

        In SE shows about 7, in GF environment shows about 5

        I've tried a few things including adding a mailcap file to my web app and playing with the glassfis-web delegate class loader flag but no luck.

        With setDebug(true) as you said, the output shows as Content-Disposition: inline; but the received email shows the jpeg as Content-Disposition: attachment;

        Show
        pranahata added a comment - Hey Bill, I deliberately made a provocative subject line to try to get attention as soon as possible. But there is something going on with the javamail implementation bundled in glassfish. The only difference i can see in both environments is the mailcap file in the METAINF of java.mail-1.5.0.jar The one in glassfish has the following two lines commented: # can't support image types because java.awt.Toolkit doesn't work on servers # #image/gif;; x-java-content-handler=com.sun.mail.handlers.image_gif #image/jpeg;; x-java-content-handler=com.sun.mail.handlers.image_jpeg I think when running on SE, there is a mailcap file in the JRE installation dir that has those two lines enabled. If i do: MailcapCommandMap mailcap = (MailcapCommandMap)CommandMap.getDefaultCommandMap(); String[] mimeTypes = mailcap.getMimeTypes(); log.debug("mailCap types are {}", Arrays.asList(mimeTypes)); In SE shows about 7, in GF environment shows about 5 I've tried a few things including adding a mailcap file to my web app and playing with the glassfis-web delegate class loader flag but no luck. With setDebug(true) as you said, the output shows as Content-Disposition: inline; but the received email shows the jpeg as Content-Disposition: attachment;
        Hide
        Bill Shannon added a comment -

        If the received message is different than the sent message, it's your mail server that's changing the message, not JavaMail.

        I have a hard time believing that the sent message is the same both in SE and in GlassFish, but different messages are being received. If that's reproducible, I'd like to see the debug output.

        The different mailcap entries shouldn't have any effect here. The mailcap entries are only used when converting a byte stream of a given MIME type to a Java object; the x-java-content-hander entry refers to the class that does the conversion. You should never need to do that when sending a message.

        It might be easier to continue debugging your problem in email; send me details at javamail_ww@oracle.com.

        Show
        Bill Shannon added a comment - If the received message is different than the sent message, it's your mail server that's changing the message, not JavaMail. I have a hard time believing that the sent message is the same both in SE and in GlassFish, but different messages are being received. If that's reproducible, I'd like to see the debug output. The different mailcap entries shouldn't have any effect here. The mailcap entries are only used when converting a byte stream of a given MIME type to a Java object; the x-java-content-hander entry refers to the class that does the conversion. You should never need to do that when sending a message. It might be easier to continue debugging your problem in email; send me details at javamail_ww@oracle.com.

          People

          • Assignee:
            Bill Shannon
            Reporter:
            pranahata
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: