MIME::Lite or /bin/mail help please

MIME::Lite or /bin/mail help please

am 02.11.2007 20:21:03 von Billy Patton

I'm trying to get a weekly to be mailed through a cron job.
I have a perl scripts that creates an excel spread sheet.
I want to attach this spread sheet to some mail and send to my group as
my weekly report.

I cat find where I can do an attachment through /bin/mail do Ive tried
MIME::Lite.

What the code does now is that it will make the attachment and send
it,but when it gets there it is empty.

Here's what I have so far:
#!/usr/local/bin/perl

use strict;
use warnings;
use MIME::Lite;
require "ctime.pl";

my $date = ctime ( time );
my $file = '/home/bpatton/c014.report.xls';
chomp $date;
my $msg = MIME::Lite->new(
From => 'bpatton@ti.com' ,
To => 'bpatton@ti.com' ,
Subject => "Weekly from Billy Patton $date",
Type => 'multipart/mixed',
);
$msg->attach(Type => 'TEXT' ,
Data => "See attachment or look at $file" ,
);
$msg->attach(Type => 'AUTO' ,
Filename => $file,
Path => '/home/bpatton',
Disposition => 'attachment' ,
);
$msg->send;

Re: MIME::Lite or /bin/mail help please

am 03.11.2007 10:06:25 von Christian Winter

Billy Patton wrote:
> I'm trying to get a weekly to be mailed through a cron job.
> I have a perl scripts that creates an excel spread sheet.
> I want to attach this spread sheet to some mail and send to my group as
> my weekly report.
>
> I cat find where I can do an attachment through /bin/mail do Ive tried
> MIME::Lite.
>
> What the code does now is that it will make the attachment and send
> it,but when it gets there it is empty.
>
[...snipped...]
> $msg->attach(Type => 'AUTO' ,
> Filename => $file,
> Path => '/home/bpatton',
> Disposition => 'attachment' ,
> );

You've got the meaning of the parameters wrong.
Filename is, as the docs for MIME::Lite explain, the name that
will be suggested to the recipient (and can differ from the name
the file has on your local disk), whereas Path has to be the
complete local path to the file. In your case, it should look
like

$msg->attach( Type => 'AUTO',
Filename => 'c014.report.xls',
Path => $file,
Disposition => 'attachment'
);

HTH
-Chris