diff options
Diffstat (limited to 'src/pop')
-rwxr-xr-x | src/pop | 26 |
1 files changed, 7 insertions, 19 deletions
@@ -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 <<INDEX; $from_ +UID: $uids{$id} Offset: $offset +Message-Length: $message_length @msg[0..$j-1] INDEX @@ -134,7 +122,7 @@ INDEX exit 130 if $sigint; # Set offset for next message - $offset += $content_length + 1; + $offset += $message_length + 1; } print STDERR "\n"; |