<p>Here's the unsatisfying resolution to this (unsatisfying because it doesn't tell you anything about the source of the bug): I did what you said and moved emails from one folder to another in chunks. Unfortunately (from the POV of bug-hunting), moving the email solved the problem. In other words, somehow the act of copying emails from one folder to another then copying them back to the original folder eliminated the error.</p>
<p>I'm not really sure how moving an email somehow fixes a header issue, but it did. So the bottom line is I now really have no idea which emails were causing the original problem because the effort to figure that out (moving to another folder then back) fixed the problem.</p>
<p>Would moving an email fix a malformed header?</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/OfflineIMAP/offlineimap/issues/172#issuecomment-85070787">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AKFSEE9Ec55_9rer_b6RZJ0nltT3drzbks5n4DMHgaJpZM4Djvum.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/OfflineIMAP/offlineimap/issues/172#issuecomment-85070787"></link>
<meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>