To recap, based on Hanno Hecker's initial, I've reworked the guts of Qpsmtp, so that the entire incoming message is stored in the spool file (including the headers). The original headers are there only so what is on the disk is a complete representation of the incoming message (for virus scanning purposes). See the attached patch.

Anyone see any reason I shouldn't commit this?

John
=== lib/Qpsmtpd/SMTP.pm
==================================================================
--- lib/Qpsmtpd/SMTP.pm  (revision 506)
+++ lib/Qpsmtpd/SMTP.pm  (local)
@@ -471,15 +471,19 @@
         # 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->{_body_start} = $size;
+
       }
 
+      # grab a copy of all of the header lines
       if ($in_header) {
         $buffer .= $_;  
       }
-      else {
-        $self->transaction->body_write($_);
-      }
 
+      # copy all lines into the spool file, including the headers
+      # we will create a new header later before sending onwards
+      $self->transaction->body_write($_);
       $size += length $_;
     }
     #$self->log(LOGDEBUG, "size is at $size\n") unless ($i % 300);
=== lib/Qpsmtpd/Transaction.pm
==================================================================
--- lib/Qpsmtpd/Transaction.pm  (revision 506)
+++ lib/Qpsmtpd/Transaction.pm  (local)
@@ -86,7 +86,8 @@
 sub body_resetpos {
   my $self = shift;
   return unless $self->{_body_file};
-  seek($self->{_body_file}, 0,0);
+  my $start = $self->{_body_start} || 0;
+  seek($self->{_body_file}, $start, 0);
   $self->{_body_file_writing} = 0;
   1;
 }
@@ -94,7 +95,8 @@
 sub body_getline {
   my $self = shift;
   return unless $self->{_body_file};
-  seek($self->{_body_file}, 0,0)
+  my $start = $self->{_body_start} || 0;
+  seek($self->{_body_file}, $start,0)
     if $self->{_body_file_writing};
   $self->{_body_file_writing} = 0;
   my $line = $self->{_body_file}->getline;

Reply via email to