IMAP mail error: Message contains invalid header.
Last week, I started getting error messages in Apple Mail when I tried to move certain messages from my inbox to another folder:
The IMAP command “APPEND” (to mailbox_name) failed with server error: Message contains invalid header.
I did some web searching and found various mentions of this issue (including in the Apple forums) but no definitive solution. I believe I know the problem, and how to fix it, at least for me.
In my situation, the internal header of the message file is getting corrupted, somehow. If you select a message that you cannot move (one that makes the above error popup), look at the raw source:
View -> Message -> Raw Source
In my case, the top line of the message was a "From:" header that shouldn't be there:
From emailremoved@yahoo.com Sat Apr 02 18:37:33 2011
Received: from nm19.bullet.mail.ne1.yahoo.com ([42.138.90.82]:35714)
by thebes.servershost.net with smtp (Exim 4.69)
(envelope-from <emailremoved@yahoo.com>)
I do not know what causes it, but if you export the Inbox out to disk:
Mailbox -> Archive Mailbox...
(Select a folder to export to.) You can then re-import the archived mail:
File -> Import Mailboxes
This will bring the messages back "On My Mac" in a folder named "Import" (or "Import-2" etc. if you do more than one). These messages seem to be fixed:
Received: from nm19.bullet.mail.ne1.yahoo.com ([42.138.90.82]:35714)
by thebes.servershost.net with smtp (Exim 4.69)
(envelope-from <emailremoved@yahoo.com>)
id 1Q69Ri-0007nu-GV
Notice there is not "From" at the top now!
So my steps to fix:
1. Select the mailbox with bad messages.
2. Archive those messages to disk.
3. Re-import the archived messages (to the "Import" folder).
4. Now that you know you have them safely back in mail, delete the original mailbox messages you just exported.
5. Copy the messages in "Import" back to the original mailbox.
NOTE: You will be deleting stuff, so watch what you are doing.
That's all I had to do to fix mine. Hope it works for others.