6 Replies Latest reply on Sep 23, 2011 2:45 AM by nathan dennis

    Seam 2.2.0.GA Mail MIME Attachment IS NOT TO SPEC

    nathan dennis Expert

      I have multiple Enterprise Systems deployed.. all using Seam 2.2.0.GA on Jboss AS..
      All have worked flawlessly sending PDF's in emails for a long time. (some of the code is years old now)
      type
      Thunderbird clients can no longer view these messages because Seams is setting the content type MIME to related. And while this is correct for inline objects, boys we got a serious problem with PDF's. Should be set to mixed to handle non graphics objects not displayed inline.


      And believe me,, i dont want to touch anything in my well oiled machine,,, talked to those nuts over at mozilla about them screwing up backwards compatibility... they pretty much send me a list of things not to do on their forum... number 1 of course being not to disagree with any of their decisions. so the truth of it is,,, ive got a problem with archived emails incorrectly formatted. and ive got an even bigger problem with seams continuing to generate emails that those who chose to adhere to the spec, wont read. 


      RFC2387 Spec


      should i even bother to file a bug report? would this be fixed in this version if i did?


      the offending bit of code is in UIBody.java


            System.out.println("related");
                          MimeMultipart bodyRootMultipart = new MimeMultipart("related");
                            //MimeMultipart bodyRootMultipart = new MimeMultipart("mixed");
                          bodyRootMultipart.addBodyPart(bodyPart, 0);
                          for (MimeBodyPart attachment: findMessage().getAttachments())
                          {
                            
                                    bodyRootMultipart.addBodyPart(attachment);
                               
                          }
                          bodyPart = new MimeBodyPart();
                          bodyPart.setContent(bodyRootMultipart);
      



      simply switching it to mixed makes these PDF's show up again.. and breaks all the inline images. (image will be attached at the bottom,, which in a formatted email blast goes over about like a fart in a diving helmet)


      i tried to just capture the type of attachment and adjust the MIME type for the PDF's.. pretty sure that is how this should work, but im not familiar enough with the workings and structure of messages to succeed on my own.
      Please help if you can, because this whole situation is spiraling from bad to really sucks in a hurry.

        • 2. Re: Seam 2.2.0.GA Mail MIME Attachment IS NOT TO SPEC
          nathan dennis Expert

          Yes.. was my first thought too... but on closer inspection the Source UIAttachment.java


             private String disposition = "attachment";
          


          so it is set to that behavior by default.. it will change the disposition to inline if you set it to that. but that doesnt have any effect in the multipart/related parent


          Message-ID: <1992253538.401315329484805.JavaMail.jboss@node1>
          Subject: Online Credit Application
          MIME-Version: 1.0
          Content-Type: multipart/mixed; 
               boundary="----=_Part_65_749177026.1315329484754"
          X-Priority: 5
          Priority: Non-urgent
          Importance: low
          X-Sent-From: Node1
          Date: Tue,  6 Sep 2011 13:18:04 -0400 (EDT)
          
          ------=_Part_65_749177026.1315329484754
          Content-Type: multipart/related;            (***********************PROBLEM IS HERE*********************)
               boundary="----=_Part_66_721653621.1315329484804"
          
          ------=_Part_66_721653621.1315329484804
          Content-Type: text/html; charset=ISO-8859-1
          Content-Transfer-Encoding: 7bit
          Content-Disposition: inline
          
          
          ------=_Part_66_721653621.1315329484804
          Content-Type: application/pdf; name=XXXXXXXXXXX.pdf
          Content-Transfer-Encoding: base64
          Content-ID: <aeamddeazitbtngdcsln>
          Content-Disposition: attachment; filename=XXXXXXXXXXX.pdf
          
          JVBERi0xLjQKJeLjz9MKMyAwIG9iaiA8PC9MZW5ndGggMTY0My9GaWx0ZXIvRmxhdGVEZWNvZGU+
          PnN0cmVhbQp4nJVY227bNhi+91MQ2MVSoGEkijrtZkucZHWRUxsPRYfe0BITc5FFl5KbeE/TR91P
          yk5s+aeTIUhgh/z+85HfByfjQRjTMCUZS2gWkXE5CMhhEoaUM/vlbDz4NPjufhn5CGd/DkLyOGCM
          xiTNGU0TEscBiTgNUmLk4HbjOM1okrvjEDlO8oAyd5pllOf90zShYeQHhzmNQ3ccJzRh/eMgppx7
          0XGa0yh1x6D17nESUz/rmOeUrY4xcATmTPxoEDzI/WgQPGBeNE8ZzbLO4oyGvH8cZzQL/egQHOJO
          



          the more i think about it.. im starting to realize why the Seam Guys wrote it this way as switching between mixed and related can get difficult to keep track of. but unfortunately, there is this poorly written spec that developers were all but ignoring in exchange for convention up until this last week when Thunderbird pushed non backward compatible code on its user base because the above convention of mixing attachment types isnt technically correctly formatted.


          where is the buzz on this forum??? i remember the old days when i would have been swamped with responses from gavin and pete for a question like this... thanks for your time Aldo

          • 3. Re: Seam 2.2.0.GA Mail MIME Attachment IS NOT TO SPEC
            nathan dennis Expert

            i would really appreciate one of the developers to address this topic at least on the forum.

            • 4. Re: Seam 2.2.0.GA Mail MIME Attachment IS NOT TO SPEC
              Aldo Bonzi Novice

              Well, as you point it out, the forum is certainly not what is was so I think you would be more than lucky if you get the their attention in the short time. Maybe a JIRA could help.


              In the mean time, I've tried to reproduce your problem but I wasn't able.


              testmail.xhtml


              <m:message xmlns="http://www.w3.org/1999/xhtml"
                  xmlns:m="http://jboss.com/products/seam/mail"
                  xmlns:p="http://jboss.com/products/seam/pdf"
                  xmlns:ui="http://java.sun.com/jsf/facelets"
                  xmlns:h="http://java.sun.com/jsf/html">
                  <m:to name="Aldo Bonzi" address="xxx@xxx.com"/>
                  <m:from name="Seam test project" address="xxx@xxx.com"/>
                  <m:subject>SEAM Test</m:subject>
              
                  <m:attachment fileName="tiny.pdf">
                      <p:document>  
                     A very tiny PDF                                                                                              
                       </p:document>
                  </m:attachment>
              
                  <m:attachment value="/img/seamlogo.png"
                                contentType="image/png"
                                fileName="seamLogo.png"
                                status="seamphoto"
                                disposition="inline"/>
                  <m:body>
                       SEAM Test
                       <img src="cid:#{seamphoto.contentId}" />
                  </m:body>
              </m:message>    
              


              Seems to work in:



              • Thunderbird 3.1.13

              • Ubuntu 11.04

              • Seam 2.2.1.Final (Did not try in 2.2.0.GA)

              • 5. Re: Seam 2.2.0.GA Mail MIME Attachment IS NOT TO SPEC
                nathan dennis Expert

                well that is easy to explain... Thunderbird didnt start following the spec until 5.x. TB 6.0 for sure will reproduce this problem. you can also verify that what i said is true by looking at the message source code.

                • 6. Re: Seam 2.2.0.GA Mail MIME Attachment IS NOT TO SPEC
                  nathan dennis Expert

                  IM A MAMAMA-MORON!!


                  JBSEAM-4630


                  i dont know how i missed that 3 weeks ago when i was hunting for info on this bug. i actually found it after i filed the bug report and had to go cancel the issue.


                  this mess is fixed in 2.2.1.CR2. i will be moving to FINAL though i have 2.2.0.GA in production in about 4 sites right now. i cant get over the inactivity on this forum though. thanks for looking at this mess... i think its just the two of us. (listens to his echo)