diff --git a/lib/Qpsmtpd/PollServer.pm b/lib/Qpsmtpd/PollServer.pm index bbeaaab..8219418 100644 --- a/lib/Qpsmtpd/PollServer.pm +++ b/lib/Qpsmtpd/PollServer.pm @@ -249,7 +249,7 @@ sub got_data { $data =~ s/\r\n/\n/mg; $data =~ s/^\.\./\./mg; - if ($self->{in_header} and $data =~ s/\A(.*?)\n[ \t]*\n//ms) { + if ($self->{in_header} and $data =~ s/\A(.*?\n)\n/\n/ms) { $self->{header_lines} .= $1; # end of headers $self->{in_header} = 0; @@ -260,7 +260,7 @@ sub got_data { # When forwarding a message into or out of the Internet environment, a # gateway MUST prepend a Received: line, but it MUST NOT alter in any # way a Received: line that is already in the header. - my @header_lines = split(/\n/, $self->{header_lines}); + my @header_lines = split(/^/m, $self->{header_lines}); my $header = Mail::Header->new(\@header_lines, Modify => 0, MailFrom => "COERCE"); @@ -271,15 +271,16 @@ sub got_data { # FIXME - call plugins to work on just the header here; can # save us buffering the mail content. + + # Save the start of just the body itself + $self->transaction->set_body_start(); } if ($self->{in_header}) { $self->{header_lines} .= $data; } - else { - $self->transaction->body_write(\$data); - } - + + $self->transaction->body_write(\$data); $self->{data_size} += length $data; }