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


in reply to mail script with attachment

The problem that appears to be occurring is that you are Base64 encoding the file name, rather than the content of the file. This is illustrated by decoding the value that appeared in the email:

$ perl -MMIME::Base64 -le 'print decode_base64(q{MTAwMWR1LnR4dA==});' 1001du.txt

MIME::Base64's documentation does not indicate that it can open a file on its own, but instead encodes the stream of bytes it is given as its first argument.

Hope that helps.