Skip navigation

IMAP mail error: Message contains invalid header.

3787 Views 9 Replies Latest reply: Mar 19, 2013 1:07 PM by rojas2 RSS
Allen Huffman Level 1 Level 1 (65 points)
Currently Being Moderated
May 2, 2011 6:40 PM

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 Sat Apr 02 18:37:33 2011

Received: from ([]:35714)

          by with smtp (Exim 4.69)

          (envelope-from <>)


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 ([]:35714)

          by with smtp (Exim 4.69)

          (envelope-from <>)

          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.

  • MikeTdoc Level 1 Level 1 (0 points)

    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 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

  • ceboyle Level 1 Level 1 (0 points)

    Did anyone send you the first line?  Were you able to write a script to fix this?  I am desperate to stop this insanity.


  • mikefromthe canyon Level 1 Level 1 (0 points)

    I'm having a little different problem. I tried to 'move' a message from the inbox to a folder, and got the message "mailbox name cntains invalid character". I've moved lots of messages in the past to this and other mailboxes, and now this problem. I recently upgraded to Mountain Lion.



  • rojas2 Level 1 Level 1 (0 points)

    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!


More Like This

  • Retrieving data ...

Bookmarked By (2)


  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.