Repair headers with envelope via offlineimap
henne.gwath at gmx.de
Sat Mar 10 17:00:51 GMT 2012
The solution to my problem of the missing HEADER lines (Date,Subject)
only stored in the ENVELOPE part of the mail was ruby.
There is a ruby-script called larch which works similar to offlineimap.
I added a small function in the file imap/mailbox.rb about line 132 of
that file to repair the broken mail (which is the sent mail). In ruby
accessing the envelope seemed to be much easier than in python. The
function looks like this:
# function, which repairs broken headers of sent mail
def repair(envelope, body)
# condition: assume mail is broken if "Date:" is missing
if body=~ /Date:/
newbody = [
In the fetch-function I added:
newbody = repair(data.attr['ENVELOPE'], data.attr['BODY'])
and used it consequently
return Message.new(guid, data.attr['ENVELOPE'], newbody,
If you experience a similar problem with you mail, consider ruby to
On 16.02.2012 16:55, Sebastian Spaeth wrote:
> On Mon, 13 Feb 2012 22:40:08 +0100, Henning Hollermann <henning.hollermann at stud.uni-goettingen.de> wrote:
>> Received messages are fetched correctly, but Sent messages break because
>> the FC-Server stores the Subject, Date and Sender not as Header-Line but
>> only in the ENVELOPE-Line.
>> I want now to repair these Headers with the corresponding fields from
>> the Envelope with offlineimap (the only program i got to work with this
>> server). But I think I have to modify the code of offlineimap itself,
>> but I don't have a clue where to start. Could someone help me on this way?
> Hi there, I don't think offlineimap will be of much help here. It never
> really looks at the content of mails or headers. (with one exception)
> I think your best bet would be a small python script that walks through
> your mails, slurps them in with the "email" module, sets the header
> correspondingly and saves the mail again.
> good luck
More information about the OfflineIMAP-project