I am trying to use MIME::Lite to send attachments to a message generated in perl. The code is below:
$msg = MIME::Lite->new(
From =>"$adminmail",
To =>"$rec[$em_ptr]",
Subject =>"$subject",
Type =>'multipart/mixed'
);
$msg->attach(Type =>'TEXT',
Data =>"$content"
);
if ($Attachments ne ""
{
@AttachmentsList = split(/\|/,$Attachments);
for ($i=1; $i<=$#AttachmentsList; $i++) {
$msg->attach(Type =>'AUTO',
Path =>'/home/andy/public_html/BaseDir/Admin/',
Filename =>"$AttachmentsList[$i]",
Disposition => 'attachment'
);
}
}
$msg->send;
I am downloading the attachment files and keeping their names in $Attachments with a format like |filename|filename|etc. When I have added all the attachments to the $Attachments variable I call this portion of code that pulls out the filenames in $Attachments and creates attchments for the e-mail message using MIME::Lite calls. Everything seems to go OK. It creates the email and when I receive it it has the proper attachments. When I use a .doc file name, the attachment even indicates a word document and when I use a .txt name it indicates a text file. However, when I try to open either of them from the e-mail they are blank even though the icon for the attached file in the e-mail shows a non-zero length. When I go and actually open the file I downloaded to the server and attached to the e-mail message it is fine. The file on the server has the information I downloaded from my pc. I've tried type of both text and auto on the attachment and that doesn't seem to do anything. Any suggestions of where I might go from here.
Thanks
Andy Cruce
$msg = MIME::Lite->new(
From =>"$adminmail",
To =>"$rec[$em_ptr]",
Subject =>"$subject",
Type =>'multipart/mixed'
);
$msg->attach(Type =>'TEXT',
Data =>"$content"
);
if ($Attachments ne ""
@AttachmentsList = split(/\|/,$Attachments);
for ($i=1; $i<=$#AttachmentsList; $i++) {
$msg->attach(Type =>'AUTO',
Path =>'/home/andy/public_html/BaseDir/Admin/',
Filename =>"$AttachmentsList[$i]",
Disposition => 'attachment'
);
}
}
$msg->send;
I am downloading the attachment files and keeping their names in $Attachments with a format like |filename|filename|etc. When I have added all the attachments to the $Attachments variable I call this portion of code that pulls out the filenames in $Attachments and creates attchments for the e-mail message using MIME::Lite calls. Everything seems to go OK. It creates the email and when I receive it it has the proper attachments. When I use a .doc file name, the attachment even indicates a word document and when I use a .txt name it indicates a text file. However, when I try to open either of them from the e-mail they are blank even though the icon for the attached file in the e-mail shows a non-zero length. When I go and actually open the file I downloaded to the server and attached to the e-mail message it is fine. The file on the server has the information I downloaded from my pc. I've tried type of both text and auto on the attachment and that doesn't seem to do anything. Any suggestions of where I might go from here.
Thanks
Andy Cruce