diff --git a/lib/Qpsmtpd/Transaction.pm b/lib/Qpsmtpd/Transaction.pm index 5c90bc3..545109d 100644 --- a/lib/Qpsmtpd/Transaction.pm +++ b/lib/Qpsmtpd/Transaction.pm @@ -217,6 +217,12 @@ sub body_fh { return shift->{_body_file}; } +sub dup_body_fh { + my ($self) = @_; + open(my $fh, '<&=', $self->body_fh); + return $fh; +} + sub DESTROY { my $self = shift; # would we save some disk flushing if we unlinked the file before @@ -380,6 +386,13 @@ Returns the file handle to the temporary file of the email. This will return undef if the file is not opened (yet). In I or later you can force spooling to disk by calling I<$transaction-Ebody_filename>. +=head2 dup_body_fh( ) + +Returns a dup()'d file handle to the temporary file of the email. This can be +useful if an external module may call close() on the filehandle that is passed +to it. This should only be used for reads, as writing to a dup'd filehandle +may have unintended consequences. + =head1 SEE ALSO L, L, L