http://www.perlmonks.org?node_id=971504


in reply to [Resolved]Email::Mime 1 email + multiple attachments

recipient will not receive 1 e-mail with 3 attachments, but 3 e-mails with 1 attachment in each e-mail

That's not too surprising, as your foreach loop is around everything.  Instead, create the list of attachments first, and then create one email to which you pass the list of attachments (@parts). I.e.

... my @parts; foreach (@files) { push @parts, Email::MIME->create( # attachments ... ); } $email = Email::MIME->create( # actual email ... parts => [ @parts ], ... ); ...