Hello,

I wrote a script which tars up a file and mails it out as a MIME attachment.

When I run it I get a message that says "no data in this part" at line 35. A
message does show up in my Inbox, but w/o the attachment.
It must be something simple but I just don't see it. Here's the code:

-----------------8<-------------------------------------8<------------------
----
#!/usr/bin/perl -w
use strict;
use MIME::Lite;

my $file = 'testfile';

-e 'testfile' or exit;

open(STDOUT, ">>my_send.log") or die "Can't open log file $!\n";
print '-' x 80, "\n";
print `date`;
print `ls -l testfile`;


# Tar it up...
my @tar = ("tar", "cvf", 'testfile.tar', 'testfile');
system(@tar) == 0 or die "my_test: failed to tar up $file! $!\n";

my $data = "A message to go in the  e-mail";

my $msg = MIME::Lite -> new(
        From    => '[EMAIL PROTECTED]',
        To      => '[EMAIL PROTECTED]',
        Subject => 'test of MIME::Lite',
        type    => 'multipart/mixed'
        ) or die "my_test: Unable to create mail message $!\n";

$msg -> attach(Type => 'TEXT',
               Data => "$data") or die "my_test: Unable to create first part
of message $!\n";

$msg -> attach(Path     => 'testfile.tar',
               Filename => 'testfile.tar',
               Encoding => 'base64') or die "my_test: unable to attach
second part $!\n";

$msg->send or die "Can't send $!\n";  # This is line 35

unlink 'testfile'     or die "Can't remove $file file $!\n";
unlink 'testfile.tar' or die "Can't remove tar file $!\n";
-----------------8<-------------------------------------8<------------------
----

Any help would be appreciated.
Thanks!





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to