#!/usr/bin/perl -w use strict; use Test::More tests => 15; use Mail::File; use File::Path; my $path = 'mailfiles'; my $temp = 'mailfiles/mail-XXXXXX.eml'; my @content = ( 'From: me@example.com', 'To: you@example.com', 'Subject: Blah Blah Blah', 'Date: ', 'Cc: Them ', 'Bcc: Us ; anybody@example.com', "X-Header-1: This is a test\n\nYadda Yadda Yadda" ); my %hash = ( From => 'me@example.com', To => 'you@example.com', Cc => 'Them ', Bcc => 'Us ; anybody@example.com', Subject => 'Blah Blah Blah', Body => 'Yadda Yadda Yadda', 'X-Header-1' => 'This is a test', template => $temp, ); mkpath $path; my $mail = Mail::File->new(%hash); is($mail->From(),'me@example.com'); is($mail->To(),'you@example.com'); is($mail->Cc(),'Them '); is($mail->Bcc(),'Us ; anybody@example.com'); is($mail->Subject(),'Blah Blah Blah'); is($mail->Body(),'Yadda Yadda Yadda'); is($mail->XHeader('X-Header-1'),'This is a test'); my $file = $mail->send(); my $exists = (-r $file ? 1 : 0); is($exists,1); open FH, $file or die "Failed to open file [$file]: $!\n"; { local $/ = undef; my $mailfile = ; for my $content (@content) { like($mailfile,qr/$content/is,"checking content includes '$content'"); } } close FH; rmtree $path;