mail message attachment not complete

Hi,
I use MIME::Lite to send an e-mail with an attachment:
$msg = MIME::Lite->new(
From =>$usermail,
To =>$tomail,
Subject =>'Nieuw Pegasus Adresboek',
Type =>'multipart/mixed'
);

$msg->attach(Type =>'TEXT',
Data =>$message
);
$msg->attach(Type =>'text/plain',
Path =>'/home/ldap/data/tine/pm_hva.txt',
Filename =>'pm_hva.txt',
Disposition => 'attachment'
);

$str = $msg->as_string;

$msg->print(\*SENDMAIL);

The problem is that the attachment is not sent complety.
It stops somewhere near the end of the file. In the file i can't find anything strange and also it happens at different lines/locations in the file..
Can anyone please help?

Tine

since you are useing single quotes it might not interperate the PATH correcly. try useing double quotes.

from the POD
http://search.cpan.org/~yves/MIME-Lite-3.01/lib/MIME/Lite.pm\#Attach\_a\_pre-prepared\_part\_to\_a_message

### Create the multipart "container":
    $msg = MIME::Lite->new(
                 From    =>'me@myhost.com',
                 To      =>'you@yourhost.com',
                 Cc      =>'some@other.com, some@more.com',
                 Subject =>'A message with 2 parts...',
                 Type    =>'multipart/mixed'
                 );

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

    ### Add the image part:
    $msg->attach(Type     =>'image/gif',
                 Path     =>'aaa000123.gif',
                 Filename =>'logo.gif',
                 Disposition => 'attachment'
                 );

unfortunately it didn't help.
It does use the right file, it just doesn't use the whole of the file..

I found out what was causing the problem..

The file i was trying to send was made in the same script before sending it:
foreach $key (@keys){
print pegasus_file $temp_naam{$key};
}

and i didn't close the file..
so it seemed to send the file before it was filled completely!

a simple
close(pegasus_file);
solved all my worries!

:slight_smile:

yeah it does help to finish printing to the file handle befor moveing it away. heh.

glad you found the problem.