if(defined($email->{'attachments'}->{'count'})){ $msg = MIME::Lite->new( From => "$email->{'from'}", To => "$row->{'email'}", Subject => "$subject", Type => 'multipart/mixed', ); if(defined($email->{'attachments'}->{'count'})){ for my $i (1 .. $email->{'attachments'}->{'count'}){ $msg->attach( Type => $email->{'attachments'}->{$i}->{'Content-type'}, Disposition => $email->{'attachments'}->{$i}->{'disposition'}, Path => $email->{'attachments'}->{$i}->{'file-path'}, Filename => $email->{'attachments'}->{$i}->{'filename'}, Encoding => 'base64', ); } }