2 # Requires the following to be installed:
5 # IO::Scalar, ... from the IO-stringy distribution
9 # Mail::Internet, ... from the MailTools distribution.
13 use Archive
::Zip
qw(:CONSTANTS :ERROR_CODES);
15 use MIME
::Entity
; # part of MIME::Tools package
18 my $SH = IO
::Scalar
->new( \
$zipContents );
20 my $zip = Archive
::Zip
->new();
23 # add a string as a member:
24 my $stringMember = '<html><head></head><body><h1>Testing</h1></body></html>';
25 $member = $zip->addString($stringMember, 'whatever.html');
26 # $member->desiredCompressionMethod(COMPRESSION_STORED);
28 # write it to the scalar
29 my $status = $zip->writeToFileHandle($SH);
32 print STDERR
"zip is ". length($zipContents). " bytes long\n";
35 my $top = MIME
::Entity
->build(
36 Type
=> 'multipart/mixed',
37 From
=> 'ned@bike-nomad.com',
38 To
=> 'billnevin@tricom.net',
39 Subject
=> "Your zip",
45 Data
=> "here is the zip you ordered\n"
50 Data
=> \
$zipContents,
51 Type
=> "application/x-zip",
53 Disposition
=> 'attachment',
54 Filename
=> 'your.zip'
63 Disposition
=> 'inline'
66 # and print it out to stdout
67 $top->print( \
*STDOUT
);