summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-05-20 03:28:57 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-05-20 03:28:57 +0200
commiteb5b7969f4d455307f5e3d82807c461ebe18fb86 (patch)
tree4661d319ebbf57878d23468a32d3d3d216e07cfd /src
parentcdf4df2126bb0fe5c33bcb77992f3877da290c17 (diff)
downloadmum-eb5b7969f4d455307f5e3d82807c461ebe18fb86.tar.gz
Add Message-Length header, remove custom headers from mbox
This way, the mbox file follows the traditional mbox format.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/pop26
1 files changed, 7 insertions, 19 deletions
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 <<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";