Skip to main content

Forwarded MacMail attachments

  5 posts   Feedicon  
Replies: 4 - Last Post: June 19, 2014 06:52
by: Bill Shannon
showing 1 - 5 of 5
Posted: October 13, 2011 17:27 by jbrackett
It appears that JavaMail isn't able to correctly parse the Body parts out of MacMail forwarded emails. The problem for me is when trying to get attachments.

--Apple-Mail=_38617397-DC2C-46BD-B4E3-779FA086FD19^M
Content-Transfer-Encoding: quoted-printable^M
Content-Type: text/html;^M
        charset=us-ascii^M
^M
<html>stuff</html>=^M
^M
--Apple-Mail=_38617397-DC2C-46BD-B4E3-779FA086FD19^M
Content-Disposition: inline;^M
        filename=my.pdf^M
Content-Type: application/pdf;^M
        name="my.pdf"^M
Content-Transfer-Encoding: base64^M
^M
JVBERi0xLjQKJfjl0MTGCjQgMCBvYmoKPDwgL1R5cGUgL1BhZ2UKL1BhcmVudCAyIDAgUgovUmVz^M
....


All of that is one "part" but only the headers in the first section get parsed. So if I ask what this parts disposition is I get null. Where clearly later in the "part" the disposition is inline. Naively it looks like there should be two parts here where the first part's disposition is null and the second parts disposition is inline.

All of this is my speculation as I don't know the javamail code base. Any thoughts?
Posted: October 18, 2011 00:03 by Bill Shannon
I really need to see the message-level headers to figure out what's going wrong here.
If the message-level headers are messed up, the entire body might look like a single
text message part.

Send me a sample message (as an attachment) at javamail_ww@oracle.com if you want.
Posted: October 18, 2011 13:47 by jbrackett
Thanks Shannon, I've forwarded you an attachment as we are doing (a pdf).
Posted: June 19, 2014 06:52 by Bill Shannon
Apple Mail is broken. Please report this problem to Apple.

RFC 2045 is quite clear that message/rfc822 parts can not be quoted-printable encoded:


Certain Content-Transfer-Encoding values may only be used on certain
media types. In particular, it is EXPRESSLY FORBIDDEN to use any
encodings other than "7bit", "8bit", or "binary" with any composite
media type, i.e. one that recursively includes other Content-Type
fields. Currently the only composite media types are "multipart" and
"message".



You can set the property "mail.mime.allowencodedmessages" to "true"
to work around this bug in Apple Mail.
Posted: June 11, 2014 14:26 by kingstonduffie
I haven't seen a resolution on this and have run into a similar problem
on 1.5.2. This is an email message that has been forwarded as an
attachment by Apple Mail. For some reason Apple Mail has chosen to
using quoted-printable for the attachment. JavaMail's
BodyPart.getContent() for the attachment returns a MimeMessage object
as expected, but that MimeMessage is corrupt -- since it appears that
it does not decode the quoted-printable contents so all of the lines
look like headers.

Here's a unit test that demonstrates the problem. Note that the
MIME_CONTENTS is pasted directly from the raw contents of an actual
email. The System.out is just to make it obvious that the MIME message
was not decoded properly.


[code]

package hive.server.mime;

import java.util.Properties;

import java.io.ByteArrayInputStream;
import java.io.IOException;

import javax.mail.BodyPart;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

import org.junit.Assert;
import org.junit.Test;

public class MimeQuotedPrintableMsgAttachment {

private static final String MIME_CONTENTS =
"Return-Path: <kduffie@sevogle.com>\n"
+ "Received: from [192.168.0.100] ([96.24.70.96])\n"
+ " by mx.google.com with ESMTPSA id gu1sm70401412pbd.0.2014.06.10.09.33.32\n"
+ " for <kduffie@sevogle.com>\n"
+ " (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);\n"
+ " Tue, 10 Jun 2014 09:33:33 -0700 (PDT)\n"
+ "From: Kingston Duffie <kduffie@sevogle.com>\n"
+ "Content-Type: multipart/mixed; boundary=\"Apple-Mail=_48C944BD-FD68-4717-98BB-9E9CF8CCCBD8\"\n"
+ "Subject: Fwd: Revised fetch\n"
+ "Message-Id: <54F2C461-712E-4A04-8A4F-C0E261E599CE@sevogle.com>\n"
+ "Date: Tue, 10 Jun 2014 09:33:32 -0700\n"
+ "To: Kingston Duffie <kduffie@sevogle.com>\n"
+ "Mime-Version: 1.0 (Mac OS X Mail 7.3 \\(1878.2\\))\n"
+ "X-Mailer: Apple Mail (2.1878.2)\n"
+ "\n"
+ "\n"
+ "--Apple-Mail=_48C944BD-FD68-4717-98BB-9E9CF8CCCBD8\n"
+ "Content-Disposition: attachment;\n"
+ " filename=\"Revised fetch\"\n"
+ "Content-Type: message/rfc822;\n"
+ " x-mac-hide-extension=yes;\n"
+ " name=\"Revised fetch\"\n"
+ "Content-Transfer-Encoding: quoted-printable\n"
+ "\n"
+ "MIME-Version:=201.0=0AReceived:=20by=2010.64.231.196=20with=20HTTP;=20=\n"
+ "Wed,=2020=20Nov=202013=2016:53:39=20-0800=20(PST)=0AX-Originating-IP:=20=\n"
+ "[96.24.70.96]=0ADate:=20Wed,=2020=20Nov=202013=2016:53:39=20-0800=0A=\n"
+ "Delivered-To:=20kduffie@sevogle.com=0AMessage-ID:=20=\n"
+ "=3cCAJU=3DD3nL99eOYG9_hsa2weY+xMd4qsg+bJMtKSiuNg8fSdo7_w@mail.gmail.com>=0A=\n"
+ "Subject:=20Revised=20fetch=0AFrom:=20Kingston=20Duffie=20=\n"
+ "=3ckduffie@sevogle.com>=0ACc:=20\"dev@hive.sevogle.com\"=20=\n"
+ "=3cdev@hive.sevogle.com>=0AContent-Type:=20multipart/alternative;=20=\n"
+ "boundary=3D047d7bd6c33c0f2dff04eba55466=0A=0A=\n"
+ "--047d7bd6c33c0f2dff04eba55466=0AContent-Type:=20text/plain;=20=\n"
+ "charset=3DISO-8859-1=0A=0AHere's=20my=20specific=20proposal=20for=20what=20=\n"
+ "we=20discussed=20regarding=20threading...=0A=0AAn=20activity=20feed=20=\n"
+ "item=20today=20includes=20ThreadSummary=20and=20MessageSummary=0Afields.=20=\n"
+ "=20Today,=20however,=20only=20one=20of=20these=20is=20populated=20=\n"
+ "depending=20on=20what=0Akind=20of=20activity=20item=20it=20is.=20=20This=20=\n"
+ "will=20change.=20=20When=20the=20user=20is=20in=0Aconversation=20view,=20=\n"
+ "the=20ThreadSummary=20will=20always=20be=20included,=20and=20the=0A=\n"
+ "MessageSummary=20will=20be=20included=20if=20the=20latest=20matching=20=\n"
+ "message=20is=20not=20the=0Alatest=20message=20in=20that=20thread.=20=20=\n"
+ "When=20not=20in=20conversation=20view,=20everything=0Aremains=20the=20=\n"
+ "same=20as=20it=20does=20today.=0A=0AThe=20client,=20then,=20will=20=\n"
+ "display=20the=20activity=20feed=20items=20exactly=20as=20it=20does=0A=\n"
+ "today=20EXCEPT=20that=20if=20the=20MessageSummary=20is=20included,=20it=20=\n"
+ "takes=20precedence=20--=0Aexcept=20for=20the=20message=20count,=20which=20=\n"
+ "comes=20from=20the=20ThreadSummary.=20=20When=20the=0Auser=20opens=20the=20=\n"
+ "thread,=20just=20as=20we=20do=20today,=20you=20will=20see=20all=20=\n"
+ "messages=20from=0Athat=20thread.=0A=0AThe=20net=20effect=20is=20that=20=\n"
+ "in=20my=20feed,=20in=20conversation=20view,=20I=20will=20see=20one=0A=\n"
+ "item=20for=20each=20thread,=20but=20showing=20the=20latest=20message=20=\n"
+ "from=20that=20thread=20that=0Amatches=20my=20search/feed-query.=20=20=\n"
+ "These=20are=20sorted=20based=20on=20the=20date=20of=20the=0Alatest=20=\n"
+ "message,=20rather=20than=20the=20thread's=20date=20--=20so=20Adam=20gets=20=\n"
+ "what=20he=0Awanted=20in=20terms=20of=20sorting.=20=20A=20new=20message=20=\n"
+ "arriving=20from=20Ameya=20does=20not=0Acause=20that=20one=20to=20pop=20=\n"
+ "to=20the=20top=20if=20Ameya=20has=20been=20excluded.=0A=0ATo=20implement=20=\n"
+ "this...=0A=0AA=20search=20request=20to=20the=20server=20is=20sent=20to=20=\n"
+ "SOLR=20to=20fetch=20matching=20activity=0Afeed=20items=20based=20on=20=\n"
+ "messages.=0A=0AIf=20the=20user's=20setting=20is=20NOT=20conversation=20=\n"
+ "view,=20then=20a=20message=20summary=20is=0Agenerated=20for=20each=20=\n"
+ "item=20and=20these=20are=20returned=20to=20the=20client.=0A=0AOtherwise,=20=\n"
+ "we=20are=20in=20conversation=20view=20mode.=0A=0A=46rom=20the=20SOLR=20=\n"
+ "items=20returned,=20the=20server=20finds=20the=20list=20of=20distinct=20=\n"
+ "thread=0AIDs=20and=20fetches=20thread=20summary=20information=20for=20=\n"
+ "each=20of=20these=20from=20Mongo=20and=0Aassembles=20a=20list=20of=20=\n"
+ "activity=20feed=20items=20accordingly.=20=20(If=20there=20aren't=0A=\n"
+ "enough=20distinct=20thread=20IDs,=20then=20we=20ask=20SOLR=20to=20fetch=20=\n"
+ "more=20items=20until=20we=0Ahave=20enough.)=0A=0AEach=20thread=20summary=20=\n"
+ "includes=20the=20message=20ID=20of=20the=20latest=20message=20in=20that=0A=\n"
+ "thread.=20=20If=20that=20message=20is=20among=20those=20returned=20from=20=\n"
+ "the=20SOLR=20query,=20then=0Awe=20have=20everything=20we=20need=20for=20=\n"
+ "that=20item.=20=20If=20not,=20then=20we=20find=20the=20latest=0Amessage=20=\n"
+ "among=20those=20returned=20from=20the=20SOLR=20query=20and=20fetch=20the=20=\n"
+ "message=0Asummary=20for=20that=20one=20from=20Mongo=20and=20update=20the=20=\n"
+ "item's=20MessageSummary=0Aaccordingly.=0A=0AAs=20it=20stands=20today,=20=\n"
+ "a=20search=20requires=20us=20to=20do=20one=20SOLR=20query,=20then=20=\n"
+ "iterate=0Ato=20get=20summaries=20(message=20or=20thread)=20for=20each=20=\n"
+ "match.=20=20With=20this=20change,=20we=0Awill=20do=20one=20SOLR=20query,=20=\n"
+ "then=20iterate=20over=20distinct=20thread=20IDs=20to=20get=0A=\n"
+ "ThreadSummaries,=20and=20then=20may=20need=20to=20do=20additional=20=\n"
+ "fetches=20for=0AMessageSummaries=20for=20the=20special=20cases.=20=20=\n"
+ "Sounds=20like=20it=20will=20scale=20pretty=0Awell.=0A=0ABy=20the=20way,=20=\n"
+ "today=20we=20actually=20do=20a=20second=20SOLR=20query=20for=20each=20=\n"
+ "search=20to=0Afind=20out=20which=20of=20the=20items=20appear=20in=20your=20=\n"
+ "main=20feed.=20=20This=20will=20go=20away.=0A=0AI'm=20going=20to=20think=20=\n"
+ "more=20about=20the=20best=20implementation=20of=20the=20\"interesting\"=0A=\n"
+ "counts/flags=20that=20we=20discussed.=0A=0A=\n"
+ "--047d7bd6c33c0f2dff04eba55466=0AContent-Type:=20text/html;=20=\n"
+ "charset=3DISO-8859-1=0AContent-Transfer-Encoding:=20quoted-printable=0A=0A=\n"
+ "=3cdiv=20dir=3D3D\"ltr\">Here&#39;s=20my=20specific=20proposal=20for=20what=20=\n"
+ "we=20discussed=20rega=3D=0Arding=20threading...=3cdiv>=3cbr>=3c/div>=3cdiv>An=20=\n"
+ "activity=20feed=20item=20today=20includes=20=3D=0AThreadSummary=20and=20=\n"
+ "MessageSummary=20fields.=20=3DA0Today,=20however,=20only=20one=20of=20=\n"
+ "the=3D=0Ase=20is=20populated=20depending=20on=20what=20kind=20of=20=\n"
+ "activity=20item=20it=20is.=20=3DA0This=20will=3D=0A=20change.=20=3DA0When=20=\n"
+ "the=20user=20is=20in=20conversation=20view,=20the=20ThreadSummary=20will=20=\n"
+ "a=3D=0Always=20be=20included,=20and=20the=20MessageSummary=20will=20be=20=\n"
+ "included=20if=20the=20latest=20ma=3D=0Atching=20message=20is=20not=20the=20=\n"
+ "latest=20message=20in=20that=20thread.=20=3DA0When=20not=20in=20con=3D=0A=\n"
+ "versation=20view,=20everything=20remains=20the=20same=20as=20it=20does=20=\n"
+ "today.=3c/div>=0A=3cdiv>=3cbr>=3c/div>=3cdiv>The=20client,=20then,=20will=20=\n"
+ "display=20the=20activity=20feed=20items=20=3D=0Aexactly=20as=20it=20does=20=\n"
+ "today=20EXCEPT=20that=20if=20the=20MessageSummary=20is=20included,=20it=20=\n"
+ "=3D=0Atakes=20precedence=20--=20except=20for=20the=20message=20count,=20=\n"
+ "which=20comes=20from=20the=20Thre=3D=0AadSummary.=20=3DA0When=20the=20=\n"
+ "user=20opens=20the=20thread,=20just=20as=20we=20do=20today,=20you=20=\n"
+ "will=3D=0A=20see=20all=20messages=20from=20that=20thread.=3c/div>=0A=\n"
+ "=3cdiv>=3cbr>=3c/div>=3cdiv>The=20net=20effect=20is=20that=20in=20my=20feed,=20=\n"
+ "in=20conversation=20view=3D=0A,=20I=20will=20see=20one=20item=20for=20=\n"
+ "each=20thread,=20but=20showing=20the=20latest=20message=20from=20=3D=0A=\n"
+ "that=20thread=20that=20matches=20my=20search/feed-query.=20=3DA0These=20=\n"
+ "are=20sorted=20based=20on=3D=0A=20the=20date=20of=20the=20latest=20=\n"
+ "message,=20rather=20than=20the=20thread&#39;s=20date=20--=20so=20Ad=3D=0A=\n"
+ "am=20gets=20what=20he=20wanted=20in=20terms=20of=20sorting.=20=3DA0A=20=\n"
+ "new=20message=20arriving=20from=20=3D=0AAmeya=20does=20not=20cause=20=\n"
+ "that=20one=20to=20pop=20to=20the=20top=20if=20Ameya=20has=20been=20=\n"
+ "excluded.=3D=0A=3c/div>=0A=3cdiv>=3cbr>=3c/div>=3cdiv>To=20implement=20=\n"
+ "this...=3cbr>=3cdiv>=3cdiv>=3cbr>=3c/div>=3cdiv>=3cdiv>A=3D=0A=20search=20request=20to=20=\n"
+ "the=20server=20is=20sent=20to=20SOLR=20to=20fetch=20matching=20activity=20=\n"
+ "fe=3D=0Aed=20items=20based=20on=20messages.=3c/div>=3cdiv>=3cbr>=3c/div>=3cdiv>If=20=\n"
+ "the=20user&#39;s=20sett=3D=0Aing=20is=20NOT=20conversation=20view,=20=\n"
+ "then=20a=20message=20summary=20is=20generated=20for=20each=20=3D=0Aitem=20=\n"
+ "and=20these=20are=20returned=20to=20the=20client.=3c/div>=0A=\n"
+ "=3cdiv>=3cbr>=3c/div>=3cdiv>Otherwise,=20we=20are=20in=20conversation=20view=20=\n"
+ "mode.=3c/div>=3cdiv>=3D=0A=3cbr>=3c/div>=3cdiv>=46rom=20the=20SOLR=20items=20=\n"
+ "returned,=20the=20server=20finds=20the=20list=20of=20d=3D=0Aistinct=20=\n"
+ "thread=20IDs=20and=20fetches=20thread=20summary=20information=20for=20=\n"
+ "each=20of=20these=3D=0A=20from=20Mongo=20and=20assembles=20a=20list=20of=20=\n"
+ "activity=20feed=20items=20accordingly.=20=3DA0(If=3D=0A=20there=20=\n"
+
Replies: 4 - Last Post: June 19, 2014 06:52
by: Bill Shannon
 
 
Close
loading
Please Confirm
Close