Here is a snipped of code that I use to send attachments to an array of email addresses. Perhaps there is something in here that will help.
#######################################################################
#######################################################################
#
# SEND BULK HTML EMAIL
#
#######################################################################
#######################################################################
sub send_bulk_email
{
use MIME::Lite;
use Net::SMTP;
my $from_address = $EMAIL{'from'};
my $mail_host = 'xxxYOURSMPTHOSTxxx';
my $subject = $FORM{'subject'};
my $message_body = $FORM{'content'};
my $to_address;
$counter = 0;
do {
$counter ++;
$to = pop @email_data;
$send_to = $to;
if ($to ne "")
{
$VALID = "NO";
&validate_address;
if ($VALID eq "YES")
{
if ($to_address)
{ $to_address .= ","; }
$to_address .= "$to";
}
}
} until ($to eq "");
### Create the multipart container
$msg = MIME::Lite->new (
From => $from_address,
Bcc => $to_address,
Subject => $subject,
Type =>'multipart/mixed'
) or die "Error creating multipart container: $!\n";
### Add the text message part
$msg->attach (
Type => 'text/html',
Data => $message_body
) or die "Error adding the text message part: $!\n";
#######################################################################
#######################################################################
#
# ATTACHMENT TYPE DEFINITONS
#
#######################################################################
#######################################################################
if ($FORM{'UploadFile'})
{
($MIME_FileName, $C_one, $void) = split (/\./, $FORM{'UploadFile'});
if ($C_one eq "doc") { $MIME_TYPE = "application/msword"; }
elsif ($C_one eq "xls") { $MIME_TYPE = "application/excel"; }
elsif ($C_one eq "pps") { $MIME_TYPE = "application/mspowerpoint"; }
elsif ($C_one eq "ppt") { $MIME_TYPE = "application/mspowerpoint"; }
elsif ($C_one eq "zip") { $MIME_TYPE = "application/zip"; }
elsif ($C_one eq "pdf") { $MIME_TYPE = "application/pdf"; }
elsif ($C_one eq "jpg") { $MIME_TYPE = "image/jpg"; }
elsif ($C_one eq "gif") { $MIME_TYPE = "image/gif"; }
else { dienice("Unknown File Type.");}
my $my_file = "/var/
my $your_file = "$FORM{'UploadFile'}";
$msg->attach (
Type => $MIME_TYPE,
Path => $my_file,
Filename => $your_file,
Disposition => 'attachment'
) or die "Error adding attachment to email: $!\n";
}
#######################################################################
#######################################################################
#
# SEND THE EMAIL
#
#######################################################################
#######################################################################
### Send the Message
MIME::Lite->send('smtp', $mail_host, Timeout=>60);
$msg->send;
if ($FILE{'UploadFile'})
{
unlink("/var/
}
}