Garbled messages in Mail.app (using Gmail IMAP)

Several of my archived messages in Gmail are displaying with garbled headers in Mail.app, which is configured to access my Gmail account via IMAP. Here's what the headers look like:

------=NextPart_000_001601CA70CE.4D0AAE80
+Content-Type: text/plain;+
charset="us-ascii"
+Content-Transfer-Encoding: 7bit+

And here's an excerpt from the body:

/9j/4AAQSkZJRgABAQEBLAEsAAD/4Q1RRXhpZgAASUkqAAgAAAACABJQBAABAAAAAQAAAGmHBAAB
AAAAJgAAAFIAAAABAIaSAgAaAAAAOAAAAAAAAABDcmVhdGVkIGJ5IEFjY3VTb2Z0IENvcnAuAAMA
KAEDAAEAAAACAAAAAQIEAAEAAAB8AAAAAgIEAAEAAADNDAAAAAAAAP/Y/+AAEEpGSUYAAQEBAAcA
BwAA/9sAQwAIBgYHBgUIBwcHCQkICgwUDQwLCwwZEhMPFB0aHx4dGhwcICQuJyAiLCMcHCg3KSww
MTQ0NB8nOT04MjwuMzQy/9sAQwEJCQkMCwwYDQ0YMiEcITIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy
MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy/8AAEQgAYABdAwEiAAIRAQMRAf/EAB8AAAEFAQEB

Note that the message displays perfectly in Gmail on the web.

Mac Pro (Early 2008) 2.8Ghz, Mac OS X (10.6.2), 10 GB RAM, 23" ACD, lots of storage!

Posted on Dec 6, 2009 7:27 AM

Reply
20 replies

Dec 6, 2009 7:43 AM in response to Badlydrawnboy

From what you've shown here, Mail is behaving correctly and what you have is a badly formatted message.

You show the MIME header (presumably for the body part) which has a content type of text/plain, which means it has essentially no formatting. Yet the body is encoded in what appears to be base64. The GMail interface apparently dopes it out somehow. But unless there are other nuances in the message that you didn't specify here, it looks like Mail is fine.

By the way, you should be able to tell from the header near the beginning of the message what email application generated the message. That would be the culprit, since it generated a badly formatted email.

Dec 6, 2009 9:08 AM in response to deh2k

I wonder if GMail re-encodes messages into base64 when it archives them. They then become non-standard format and can't be viewed reliably by other email clients.


I don't understand that point. The only reason base64 could not be viewed reliably by any email client is if there is no header or the wrong header for the content-transfer-encoding, and that is clearly an defect on the part of the app doing the encoding. The same would go for quoted-printable.

Jan 18, 2010 6:41 AM in response to Badlydrawnboy

I'm having the same problem. Some emails from gmail come in garbled. they usually have attachedments and they always are fine when I first view them. It's only when I got back to view them again that they are garbled. I am using IMAP and DO NOT store messages locally.

If I quite Mail and start it again, the messages are fine. Seems like there is a bug between Gmail and Mail

Jan 19, 2010 7:00 AM in response to pxforti

I have the same problem, pxforti described the symptoms perfectly. The problem does not happen at first, I even replied to the messages in question. The problem only happened after moving the messages to another IMAP folder.

Unfortunately quitting and starting Mail.app again did not fix the problem on my side.

Also, in my case the messages appear to start like this:

------ =_NextPart_00101CA98EF.4C667739
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: base64

SGkgQXR0aWxhLiBOby4gSSBkaWRu4oCZdCBkaXNjdXNzIHdpdGggTUsgYnkgbm93LiBCdXQgdGhp
cyBpcyBoaWdoZXN0IHByaW8uIENvbWluZyBmcm9tIFJULiBJIHNlbmQgTXIuIEVsbGluZ2hhdXMg
--8<--- snip

Jan 19, 2010 9:00 PM in response to Attila Tajti

After checking the messages again I realized that they had no headers at all. No From/To adresses, no Subject etc. Clicking "Long Headers" does not show anything either. Looks like Mail.app thinks the message starts with "------ =NextPart...".

I also decoded the base64 in question and found that they contain the message text only, again with no headers at all. I verified that the text is the same as the one on the Gmail web. Also, the headers are not missing there. (The headers must be correct on the Gmail web side anyway, otherwise it could not display the messages in its threaded view anyway.)

So it must be a Mail.app synchronization issue that happens with Gmail only. I wonder if other mail apps exhibit this behavior?

Jan 20, 2010 1:44 AM in response to Badlydrawnboy

I have exactly the same problem. I've used gmail for about a year now, through OS/X 10.5 and 10.6. Right after I performed the 10.6 upgrade, some MIME messages from gmail are not being parsed properly. I brushed it off the first two times but after the third I thought it was time to hit the forums, and voila. Some things I've noted:

1. It has happened from senders using both Outlook 2003 and Mac Mail on Snow Leopard, so the sender's client does not seem to matter.

2. It sometimes happens sporadically. For example, one sender sent three emails, each with 5 jpeg attachments. Only one of the sender's messages was garbled. That sender was using Mac Mail on 10.6.

3. Messages always display properly in the gmail web interface.

I think there's something for Apple to take care of on this one.

Jan 20, 2010 8:47 AM in response to phinaesgage

I checked my Gmail account from Thunderbird, and it looks perfect there. The garbled messages in Mail.app seems to correspond to the plain-text version of the original message, but encoded in base64 in my case. Definitely a Mail.app Gmail synchronization issue. Perhaps Mail.app moves messages between IMAP mailboxes in a way that causes this. I also happened to set my Gmail messages to be forwarded to MobileMe, and the same messages look fine there. For the time being I will just access my mail through MobileMe.

Jan 20, 2010 9:43 PM in response to Attila Tajti

Yesterday I tried to move all my messages from Gmail to MobileMe to work around this. I created a new label "Archive" in Gmail web and marked all my mail in "All Mail" with this label so they would show up in IMAP. In Mail.app I disabled "Move messages to Trash" to avoid having them deleted.

Unfortunately I could not move my messages, around 1 out of 50 had the problem described above, so MobileMe did not allow me to upload them because of the missing headers. These were old messages, never opened by Mail.app earlier, and it was true that they missed some headers: they were exported from Outlook and Opera Mail years ago. But still they had all the header fields a mailer would display (To, From, Cc, Subject). Anyway the fact Mail.app cannot display these properly is perhaps acceptable in this case.

However the problem being unable to display certain recently received, archived messages on my Gmail account still applies. Those messages were not modified in any way, only Gmail and Mail.app were used to access them.

Needless to say, the old messages mentioned above that went through Outlook and Opera Mail look OK both on the web and in Thunderbird, too. At least I knew that I realized early that I could not move all messages this way to MobileMe. I am going to try moving my messages again with Thunderbird now.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Garbled messages in Mail.app (using Gmail IMAP)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.