[...] my %attachments; for (@imgfiles) { $attachments{$_} = { _disptype => 'GIF Image', _inline => $_, description => 'ATM-Image', ctype => 'image/gif', file => $imgdirfiles }; } email({ from => 'alice@example.com', to => 'bob@example.com', [...] _attachments => \%attachments }) or die "sending mail failed: $@"; [...]