#!/usr/bin/perl -w

use lib '..';
use Mail::Message;

my $infile   = '/etc/group';
my @prelude  = <<PRELUDE;
  This message is in MIME format.  The following part
  is BASE64 encoded and contains encrypted data.

PRELUDE

my $filename = 'filename_clientside.txt';
my $to       = 'wiggins@danconia.org';
my $subject  = 'Sample subject line';
my %xheaders = (Status => '1', OrigName => 'original file name');

my $preamble = Mail::Message::Body::Lines->new
   ( 'disposition' => 'inline',
   , 'data' => \@prelude,
   );

my $attachment = Mail::Message::Body::File->new
   ( file => $infile
   , disposition => "attachment; filename=\"$filename\""
   );

my $body = Mail::Message::Body::Multipart->new
   ( preamble => $preamble
   , parts    => [ $attachment ]
   );

my $msg = Mail::Message->buildFromBody
  ( $body

  , To       => $to
  , Subject  => $subject
  );

my $head = $msg->head;
$head->add("X-$_" => $xheaders{$_})
    foreach sort keys %xheaders;

$msg->print;
