... for my $ja (0 .. $ja_max - 1) { my $attachBinaryFile = $attach_list[$ja]; my $content_type; if ($attachBinaryFile =~ /\.gif$/i) { $content_type = 'image/gif' } elsif ($attachBinaryFile =~ /\.jpg$/i) { $content_type = 'image/jpeg' } elsif ($attachBinaryFile =~ /\.zip$/i) { $content_type = 'application/zip' } elsif ($attachBinaryFile =~ /\.html$/i) { $content_type = 'text/html' } elsif ($attachBinaryFile =~ /\.pdf$/i) { $content_type = 'application/pdf' } elsif ($attachBinaryFile =~ /\.xls$/i) { $content_type = 'application/vnd.ms-excel' } elsif ($attachBinaryFile =~ /\.doc$/i) { $content_type = 'application/vnd.ms-word' } elsif ($attachBinaryFile =~ /\.log$/i) { $content_type = 'application/octet-stream' } else { warn "Unrecognized file type: $attachBinaryFile"; next; } $smtp->datasend("--$boundary\n"); ...