[sf-perl] MIME::Lite

Peter Loo loopeter at yahoo.com
Fri Jul 24 09:28:28 PDT 2009

Hi Thomas,

It is very strange.  I ran your code after changing email addresses and my file name and it worked.  I will see why mine isn't working.

Thanks for all your help.


--- On Fri, 7/24/09, Thomas Brightbill <thomas at brightbill.net> wrote:

From: Thomas Brightbill <thomas at brightbill.net>
Subject: Re: [sf-perl] MIME::Lite
To: "San Francisco Perl Mongers User Group" <sanfrancisco-pm at pm.org>
Date: Friday, July 24, 2009, 12:46 AM

Peter Loo wrote:

>   my $fileName = "stravinsky09.gif";
>   my $datDir = "/the/path/to/my/file";

>   $message->attach ( Type     => 'application/gif',
>                      Path     => $datDir,
>                      #Encoding => 'base64',
>                      Filename => $fileName,
>                      Disposition => 'attachment' );

I've used MIME::Lite a couple times but have never run across this before.  I would suggest changing 'Path' as follows

  Path => $datDir/$filename,

The MIME::Lite documentation says


    Alternative to "Data" or "FH". Path to a file containing the
    data... actually, it can be any open()able expression. If it
    looks like a path, the last element will automatically be
    treated as the filename. See "ReadNow" also.

In your example above, I'm wondering if it's looking for "file" as the filename.

I also found it helpful to turn on debugging with

  $msg->send('smtp','localhost', Debug=>1);

Here's my working test script:



use strict;

use MIME::Lite;

### Create the multipart "container":
my $msg = MIME::Lite->new(
    From    =>'thomas at brightbill.net',
    To      =>'thomas at brightbill.net',
    Subject =>'A message with 2 parts...',
    Type    =>'multipart/mixed'

### Add the text message part:
### (Note that "attach" has same arguments as "new"):
    Type     =>'TEXT',
    Data     =>"Here's the spreadsheet file you wanted"

### Add the spreadsheet:
    Type        =>'application/vnd.ms-excel',
    Path        =>'/home/thomas/testfile.xls',
    Filename    =>'testfile.xls',
    Disposition => 'attachment'

$msg->send('smtp','localhost', Debug=>1);



-- Thomas Brightbill
thomas at brightbill.net

SanFrancisco-pm mailing list
SanFrancisco-pm at pm.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20090724/a84cd885/attachment-0001.html>

More information about the SanFrancisco-pm mailing list