in reply to Capturing Email During Testing

I'm not sure what the "system call" has do do with your issue (you don't show any sample code), but maybe the following will give you a different tool to play with:

#!/usr/bin/perl use strict; use warnings; use Test::MockObject; BEGIN { my $mockMIMELite = Test::MockObject->new(); my %params = (To => 'parp', Subject => 'Beep', From => 'Bop'); $mockMIMELite->fake_module( 'MIME::Lite', new => sub {ML_new($mockMIMELite, @_)}, send => sub { }, ); $mockMIMELite->mock(send => \&ML_send); $mockMIMELite->mock(attach => \&ML_attach); } use MIME::Parser; my $msg = MIME::Lite->new( To => 'wibble@wobble', From => 'Bogus email source', Subject => 'Email test', Data => 'Email body', ); $msg->send(); sub ML_new { my ($mock, $class, %params) = @_; $mock->{newParams} = \%params; return $mock; } sub ML_send { my ($self) = @_; my %fields = %{$self->{newParams}}; my @headerKeys = ( (grep {exists $fields{$_}} qw(To From Cc Subject)), (grep {!/^(data|subject|cc|to|from)$/i} sort keys %fields) ); print "--------------8<------------------\n"; print "$_: $self->{newParams}{$_}\n" for grep {defined $self->{newParams}{$_}} @headerKeys; print "Data:\n$self->{newParams}{Data}\n"; print "-------------->8------------------\n\n"; return 1; } sub ML_attach { my ($self, %params) = @_; my %fields = %{$self->{newParams}}; print ".............-8<..................\n"; print "Type: $params{Type}\n"; print "Path: $params{Path}\n"; print "Filename: $params{Filename}\n"; print "Disposition: $params{Disposition}\n"; print ".............-8<..................\n"; return 1; }

Prints:

--------------8<------------------ To: wibble@wobble From: Bogus email source Subject: Email test Data: Email body -------------->8------------------
True laziness is hard work