From eb5b7969f4d455307f5e3d82807c461ebe18fb86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 20 May 2021 03:28:57 +0200 Subject: Add Message-Length header, remove custom headers from mbox This way, the mbox file follows the traditional mbox format. --- src/pop | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'src/pop') diff --git a/src/pop b/src/pop index 3134c14..8151010 100755 --- a/src/pop +++ b/src/pop @@ -96,25 +96,11 @@ for my $id (@ids) { $from = 'MAILER-DAEMON@' . hostname if not $from; my $from_ = "From $from $date"; - # Add UID header - unshift @msg, "UID: $uids{$id}"; $j++; - - # Add Content-Length header - my ($header_length, $body_length, $content_length); - $header_length += length($_)+1 for (@msg[0..$j-1]); + # Calculate message length + my ($head_length, $body_length, $message_length); + $head_length += length($_)+1 for (@msg[0..$j-1]); $body_length += length($_)+1 for (@msg[$j..$#msg]); - $content_length = length($from_) + 1 + $header_length + $body_length; - - # - Add length of Content-Length header to Content-Length - my $new = $content_length; - my $prev = 0; - until ($new == $prev) { - $prev = $new; - $new = $content_length + length "Content-Length: $content_length\n"; - } - $content_length = $new; - - unshift @msg, "Content-Length: $content_length"; $j++; + $message_length = length($from_) + 1 + $head_length + $body_length; # Append message to mbox and index files local $" = "\n"; @@ -126,7 +112,9 @@ $from_ MBOX print $index <