in reply to Collecting a list of filenames together

You declare
my @result = ();
but don't use it.

I would take all the smtp stuff out of the sub and replace it with

push @result, $string;
and then at the end of the script send the results (perhaps with some prettifying).
my $email_body = join qq{\n******\n}, @results;
update: changed the last sentence into something closer to English.