Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-27062

email-ext-plugin: configurable attachment mime type

    • Icon: New Feature New Feature
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • email-ext-plugin
    • None

      Hello, using email-ext-plugin and hit a problem. I want to attach an html report to the message but it is attached as

      Content-Type: application/octet-stream; name=report.html

      As a result mailers like thunderbird display garbled content (or not at all).

      I think it would be very useful to have ability to specify content type of attached files (e.g. text/html).

          [JENKINS-27062] email-ext-plugin: configurable attachment mime type

          Alex Earl added a comment -

          That's strange, apparently the MimetypesFileTypeMap.getDefaultFileTypeMap() is returning application/octet-stream for .html. I don't think specifying the content type will happen since attachments are done using patterns.

          Alex Earl added a comment - That's strange, apparently the MimetypesFileTypeMap.getDefaultFileTypeMap() is returning application/octet-stream for .html. I don't think specifying the content type will happen since attachments are done using patterns.

          akostadinov added a comment - - edited

          Good points. I looked again and it appears my htmls were not generated with proper HTML header and footer. Let me try again with proper HTML and I'll report back.

          akostadinov added a comment - - edited Good points. I looked again and it appears my htmls were not generated with proper HTML header and footer. Let me try again with proper HTML and I'll report back.

          Alex Earl added a comment -

          I am unable to reproduce this issue. The mime type is set correctly when I attach HTML files with the extension '.html'

          Alex Earl added a comment - I am unable to reproduce this issue. The mime type is set correctly when I attach HTML files with the extension '.html'

          Code changed in jenkins
          User: Alex Earl
          Path:
          src/test/java/hudson/plugins/emailext/AttachmentUtilsTest.java
          src/test/resources/test.html
          http://jenkins-ci.org/commit/email-ext-plugin/c27c465b6c481f2c0c956df2067a927357b8bb78
          Log:
          Test for JENKINS-27062

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: src/test/java/hudson/plugins/emailext/AttachmentUtilsTest.java src/test/resources/test.html http://jenkins-ci.org/commit/email-ext-plugin/c27c465b6c481f2c0c956df2067a927357b8bb78 Log: Test for JENKINS-27062

          akostadinov added a comment -

          I tried attaching a proper HTML. Firefox shows it as standard compliance mode. Still attached as and application/octet-stream. Let me try to craft a reproducer. I'll need a little time.

          akostadinov added a comment - I tried attaching a proper HTML. Firefox shows it as standard compliance mode. Still attached as and application/octet-stream. Let me try to craft a reproducer. I'll need a little time.

          Alex Earl added a comment -

          Can you provide more details about your OS and so forth?

          Alex Earl added a comment - Can you provide more details about your OS and so forth?

          akostadinov added a comment -

          The attached empty body HTML is also attached as `application/octet-stream`.

          We're running latest stable jenkins release `1.580.3`. Latest email-ext-plugin. Openjdk 1.6 running on linux. JDK is not updated very recently though.

          akostadinov added a comment - The attached empty body HTML is also attached as `application/octet-stream`. We're running latest stable jenkins release `1.580.3`. Latest email-ext-plugin. Openjdk 1.6 running on linux. JDK is not updated very recently though.

          akostadinov added a comment -

          ok, used a very simple groovy script:

          import javax.activation.MimetypesFileTypeMap;
          
          println MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType("filename")
          

          And it appears local java version returns `application/octet-stream` while newer openjdk returns `text/html`.

          Do you think anything can be done on the plugin side or is my only option to get back to java vendor/change java version used? Any other workarounds you may know? Using a pre-send script to change mime-type?

          akostadinov added a comment - ok, used a very simple groovy script: import javax.activation.MimetypesFileTypeMap; println MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType( "filename" ) And it appears local java version returns `application/octet-stream` while newer openjdk returns `text/html`. Do you think anything can be done on the plugin side or is my only option to get back to java vendor/change java version used? Any other workarounds you may know? Using a pre-send script to change mime-type?

          akostadinov added a comment - - edited

          I found out what's the issue. The local jvm does not have default mime.types defined. When I

          ln -s /etc/mime.types ~/.mime.types
          

          Without this all files were translated to application/octet-stream.
          The jvm finds the file and uses it to correctly map files to mime types. I filed a bug with the OS.

          If you believed there is no room for improvement for the plug-in, you can close the issue.

          Regards and thank you for looking into this.

          akostadinov added a comment - - edited I found out what's the issue. The local jvm does not have default mime.types defined. When I ln -s /etc/mime.types ~/.mime.types Without this all files were translated to application/octet-stream. The jvm finds the file and uses it to correctly map files to mime types. I filed a bug with the OS. If you believed there is no room for improvement for the plug-in, you can close the issue. Regards and thank you for looking into this.

            slide_o_mix Alex Earl
            akostadinov akostadinov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: