Add ARM files
[dh-make-perl] / dev / arm / libarchive-zip-perl / libarchive-zip-perl-1.18 / debian / libarchive-zip-perl / usr / share / doc / libarchive-zip-perl / examples / mailZip.pl
1 #!/usr/bin/perl -w
2 # Requires the following to be installed:
3 #  File::Path
4 #  File::Spec
5 #  IO::Scalar, ...         from the IO-stringy distribution
6 #  MIME::Base64
7 #  MIME::QuotedPrint
8 #  Net::SMTP
9 #  Mail::Internet, ...     from the MailTools distribution.
10 #  MIME::Tools
11
12 use strict;
13 use Archive::Zip qw(:CONSTANTS :ERROR_CODES);
14 use IO::Scalar;
15 use MIME::Entity;    # part of MIME::Tools package
16
17 my $zipContents = '';
18 my $SH          = IO::Scalar->new( \$zipContents );
19
20 my $zip = Archive::Zip->new();
21 my $member;
22
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);
27
28 # write it to the scalar
29 my $status = $zip->writeToFileHandle($SH);
30 $SH->close;
31
32 print STDERR "zip is ". length($zipContents). " bytes long\n";
33
34 ### Create an entity:
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",
40 );
41
42 # attach the message
43 $top->attach(
44     Encoding => '7bit',
45     Data     => "here is the zip you ordered\n"
46 );
47
48 # attach the zip
49 $top->attach(
50     Data     => \$zipContents,
51     Type     => "application/x-zip",
52     Encoding => "base64",
53         Disposition => 'attachment',
54         Filename => 'your.zip'
55 );
56
57 # attach this code
58 $top->attach(
59         Encoding => '8bit',
60         Type => 'text/plain',
61         Path => $0,
62         # Data => 'whatever',
63         Disposition => 'inline'
64 );
65
66 # and print it out to stdout
67 $top->print( \*STDOUT );