You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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.

Posted on May 2, 2011 6:40 PM

Reply
14 replies

May 10, 2011 6:05 PM in response to Allen Huffman

Further information:


I have done more testing, as this problem keeps happening. I have discovered that mail with this invalid header can be moved between mail accounts on the web server I use, or even to GMail, but if I move them to a subfolder on my me.com account, I get this error.


I clearly see that some messages have this "From xxxx" header at the top, and they cause a problem, while others that do not work fine.


But it also seems clear that this issue with the APPEND error is coming from me.com, as my web server accounts and Gmail handle it just fine.


Any ideas? I am tired of the archive/restore dance to fix this.

May 11, 2011 7:04 AM in response to Allen Huffman

My webhost provider was able to shed more light on the subject, and provide me a link to a description of the cause:

http://kb.mozillazine.org/Message_contains_invalid_header


I suppose the issue is with how Mac Mail is storing the mail file, and the me.com server not liking the mbox "From " header getting placed in there.


I wonder if something changed a few weeks ago to cause this issue to pop up for me? Hundreds of e-mails a day, and I have never seen this problem before.

Mar 18, 2012 9:27 AM in response to Allen Huffman

My error is different, but I was desperate and tried the export/imprt dance you used for the header problem. I am trying to move the last 350 messages from my MacMail POP3 account to iCloud ...me.com account. The other 8,000+ messages worked fine. The export/import did not correct the error, but wanted to let people know.


My error:


The IMAP command “APPEND” (to [mailbox name]) failed with server error: Message contains NUL characters.


I have not yet found a solution, but interested in hearing from anyone with the same problem. Thanks, Mike

May 19, 2012 12:36 PM in response to Allen Huffman

Update: In Mac OS X 10.7 (Lion), the Mail is updated so the Archive menu option is not there. It is called Export now.


  1. Select the mailbox under "MAILBOXES".
  2. Chose the "Mailbox -> Export Mailbox..." menu option. Choose a location for it to write out the file (mine was called INBOX.mbox).
  3. Choose the "File -> Import Mailboxes..." menu option. Browse to where you saved out the .mbox file, and select it.
  4. The messages inside the .mbox file will be reimported, and show up as a subfolder under "ON MY MAC" called "Import". Expand "Import" and you should see "INBOX" or whatever mailbox name you exported. You can then drag those messages to where you want them, and their headers will be fixed.


But why does this happen?

Mar 19, 2013 1:07 PM in response to Allen Huffman

I don't know if anyone else is having this problem still but I think that I managed to find a fix:


I went to the Preferences in the mail app and then disable the yahoo account (where i wanted the message stored but not where it came from)

I completely quit the Mail app

after a few seconds, reopened it

renabled the yahoo account


And now it is working!


I hope this helps others, good luck!

May 24, 2014 3:44 AM in response to Allen Huffman

Hi Allen,


I've just had the same problem in Mail: The IMAP command “APPEND” (to mailbox_name) failed with server error: Message contains invalid header.


I'm trying to move some Mailbox/Folders from being located on my Mac to being located on iCloud.com


Essentially I was dragging a Mailbox on my Mac to being on iCloud. Then the error pops up. It seems the error occurs only on old emails, mostly before the year 2000.


Exporting & reimporting the Mailboxes didn't fix the problem for me.



My solution is a little convulted, but worked using Outlook.com (what was Hotmail) as a go between.


Quick answer: Move email from Mail.app to Outlook.com and back again.



Long answer:


Step 1:


Setup an IMAP Outlook.com account in Mail.app


Go to Outlook.com in a web browser, create two Folders. I titled them: Repair & Fixed.


This is to keep messages your moving separate from your Outlook.com inbox.


These two folders/mailboxes should appear in the sidebar in Mail.app.



Step 2:


Select emails from a Mailbox/folder which has problem emails, drag them to the Repair folder.


This moves them from your computer to Outlook.com


Once complete.


Go to Outlook.com in a web browser and move the emails from Repair to Fixed*



In Mail.app. All the mails will now appear in the Fixed Mailbox/Folder (if it's not appearing, try quitting Mail and opening it again).


Select all the mail now in the Fixed mailbox/folder, and move them to a Mailbox/Folder of your choice on iCloud.


The mails then all copy accross without any errors.



It's a little long winded and some steps may not be needed. Hopefully this might help some people with the issue.



* You may not need to move the mail between the two folders on Outlook.com. When I tried just moving mail from Mail.app to Outlook.com and back it still gave the error. Moving it within Outlook.com seemed to fix the mails for me.






I'm using a MacBook running 10.9.3 Mavericks, not Snow Leopard but the basic principles should remain the same.

IMAP mail error: Message contains invalid header.

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